diff --git a/src/routes/store.ts b/src/routes/store.ts index fec2035d..82f79e22 100644 --- a/src/routes/store.ts +++ b/src/routes/store.ts @@ -7,6 +7,6 @@ themeVariant.subscribe((value) => { localStorage.setItem('themeVariant', value); }); -export const activeFile = writable(null); +export const currentFile = writable(null); -activeFile.set(new Assignment({})); +currentFile.set(new Assignment({})); diff --git a/src/routes/workspace/FileViewer.svelte b/src/routes/workspace/FileViewer.svelte index b0279345..f423b01e 100644 --- a/src/routes/workspace/FileViewer.svelte +++ b/src/routes/workspace/FileViewer.svelte @@ -6,7 +6,7 @@ import SideBarElem from './SideBarElem.svelte'; import randomName from '$lib/randomName'; import { fileStore, type FileInfo } from '@/api/apiStore'; - import { activeFile } from '../store'; + import { currentFile } from '../store'; const api = getContext('api') as ApiHandler; @@ -22,9 +22,9 @@ { - activeFile.set(file); + currentFile.set(file); }} - active={file?.id == $activeFile?.id} + active={file?.id == $currentFile?.id} id={file?.id} > @@ -39,7 +39,7 @@ if (!response) return; return response.json(); }); - activeFile.set(newFile); + currentFile.set(newFile); fileStore.update((before) => [...before, newFile]); }} class="reset no-bg size-full" diff --git a/src/routes/workspace/editor/+page.svelte b/src/routes/workspace/editor/+page.svelte index 8a57d0cc..bd92bf1f 100644 --- a/src/routes/workspace/editor/+page.svelte +++ b/src/routes/workspace/editor/+page.svelte @@ -2,7 +2,7 @@ import Toolbar from './Toolbar/Toolbar.svelte'; import FileEditor from './FileEditor.svelte'; import Workspace from '../Workspace.svelte'; - import { activeFile } from '../../store'; + import { currentFile } from '../../store'; import { getContext } from 'svelte'; import ApiHandler from '@/api'; import type { Readable } from 'svelte/store'; @@ -23,17 +23,17 @@ api.getDocument(id || '').then((file) => { if (!file) return; file.json().then((fileContent) => { - activeFile.set(fileContent); + currentFile.set(fileContent); }); }); - {$activeFile?.name || 'Editor'} | Akademia + {$currentFile?.name || 'Editor'} | Akademia - {#if $activeFile} + {#if $currentFile}
diff --git a/src/routes/workspace/editor/Toolbar/MoreActions.svelte b/src/routes/workspace/editor/Toolbar/MoreActions.svelte index 4cd305ae..8af43b50 100644 --- a/src/routes/workspace/editor/Toolbar/MoreActions.svelte +++ b/src/routes/workspace/editor/Toolbar/MoreActions.svelte @@ -3,7 +3,7 @@ import * as Dialog from '$lib/components/ui/dialog'; import Button from '@/components/ui/button/button.svelte'; import { MoreHorizontal, Trash2, LogOut, Download, Printer } from 'lucide-svelte'; - import { activeFile } from '../../../store'; + import { currentFile } from '../../../store'; import { getContext } from 'svelte'; import type ApiHandler from '@/api'; import { fileStore } from '@/api/apiStore'; @@ -12,13 +12,13 @@ const api = getContext('api') as ApiHandler; function deleteActiveFile() { - const id = $activeFile?.id; + const id = $currentFile?.id; if (!id) return; api.deleteDocument(id).then((response) => { if (!response || response.status !== 200) return; console.log(response); - fileStore.update((prev) => prev.filter((it) => it !== $activeFile)); - activeFile.set(null); + fileStore.update((prev) => prev.filter((it) => it !== $currentFile)); + currentFile.set(null); }); isDeleteOpen = false; } @@ -78,7 +78,7 @@ - Er du sikker på, at du vil slette {$activeFile?.name}? + Er du sikker på, at du vil slette {$currentFile?.name}? Dette sletter filen permanent. Denne handling kan ikke fortrydes diff --git a/src/routes/workspace/editor/Toolbar/ShareDocument.svelte b/src/routes/workspace/editor/Toolbar/ShareDocument.svelte index c20d550e..302c57fe 100644 --- a/src/routes/workspace/editor/Toolbar/ShareDocument.svelte +++ b/src/routes/workspace/editor/Toolbar/ShareDocument.svelte @@ -9,7 +9,7 @@ import { Separator } from '$lib/components/ui/separator'; import { getContext, onMount } from 'svelte'; import type ApiHandler from '@/api'; - import { activeFile } from '../../../store'; + import { currentFile } from '../../../store'; import type { FileInfo } from '@/api/apiStore'; const api = getContext('api') as ApiHandler; @@ -63,7 +63,7 @@ let people: Member[] = []; - $: $activeFile && findMembers($activeFile); + $: $currentFile && findMembers($currentFile); function findMembers(activeFile: FileInfo) { people = []; @@ -98,10 +98,10 @@ } function addUserToDocument() { - if (!$activeFile) return; + if (!$currentFile) return; var email = (document.getElementById('invite-email') as HTMLInputElement).value; console.log(email); - api.addUserToDocument($activeFile?.id, email).then((response) => { + api.addUserToDocument($currentFile?.id, email).then((response) => { console.log(response); }); } @@ -121,7 +121,7 @@ - Del '{$activeFile?.name || ''}' + Del '{$currentFile?.name || ''}' Kun personer, du inviterer, kan få adgang til dette dokument. Du kan ændre tilladelsen for hver person. @@ -130,7 +130,7 @@