mirror of
https://gitlab.com/cyclane/sbdatatracker.git
synced 2025-08-02 12:11:14 +00:00
first somewhat stable version
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
<script lang="ts">
|
||||
export let hrefPrefix = "";
|
||||
import { login } from "./stores";
|
||||
import { getGraphs } from "../lib/api";
|
||||
import { checkPermissions, Permissions } from "../lib/permissions";
|
||||
import { getGraphs, getPermissions } from "../lib/api";
|
||||
|
||||
let add = false;
|
||||
let graphsPromise: ReturnType<typeof getGraphs> = new Promise(() => {});
|
||||
$: if ($login !== undefined) {
|
||||
graphsPromise = getGraphs($login?.token);
|
||||
getPermissions($login?.token).then(permissions => {
|
||||
if (checkPermissions([Permissions.ADD_GRAPH], permissions)) {
|
||||
add = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -23,7 +30,9 @@
|
||||
</a>
|
||||
{/each}
|
||||
<!-- svelte-ignore a11y-missing-content -->
|
||||
<a class="item add" href="/graph/new" />
|
||||
{#if add}
|
||||
<a class="item add" href="/graph/new" />
|
||||
{/if}
|
||||
{:catch error}
|
||||
<span class="item">
|
||||
<h2 style="color: red">{error.message}</h2>
|
||||
|
@@ -50,27 +50,6 @@ function createExtraNav() {
|
||||
|
||||
export const extraNav = createExtraNav();
|
||||
|
||||
function createCache() {
|
||||
const { subscribe, set, update } = writable<{
|
||||
[key: string]: string;
|
||||
}>({});
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
set: (key: string, value: string) =>
|
||||
update(current => ({
|
||||
...current,
|
||||
[key]: value
|
||||
})),
|
||||
unset: (key: string) =>
|
||||
update(current => {
|
||||
delete current[key];
|
||||
return current;
|
||||
}),
|
||||
clear: () => set({}),
|
||||
update
|
||||
};
|
||||
}
|
||||
|
||||
export const playerCache = createCache();
|
||||
export const profileCache = createCache();
|
||||
export let playerCache: Record<string, string> = {};
|
||||
export let uuidCache: Record<string, string> = {};
|
||||
export let profileCache: Record<string, string> = {};
|
||||
|
Reference in New Issue
Block a user