first somewhat stable version

This commit is contained in:
2021-07-18 22:53:48 +01:00
parent d96fb38aa1
commit 2374023667
9 changed files with 132 additions and 46 deletions

View File

@@ -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>

View File

@@ -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> = {};