Skip to content

Commit

Permalink
rename activeFile -> currentFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Ell1ott committed Feb 28, 2024
1 parent 31bd144 commit 9c5d560
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/routes/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ themeVariant.subscribe((value) => {
localStorage.setItem('themeVariant', value);
});

export const activeFile = writable<FileInfo | null>(null);
export const currentFile = writable<FileInfo | null>(null);

activeFile.set(new Assignment({}));
currentFile.set(new Assignment({}));
8 changes: 4 additions & 4 deletions src/routes/workspace/FileViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,9 +22,9 @@
<File
name={file?.name}
onClick={() => {
activeFile.set(file);
currentFile.set(file);
}}
active={file?.id == $activeFile?.id}
active={file?.id == $currentFile?.id}
id={file?.id}
></File>
</div>
Expand All @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions src/routes/workspace/editor/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -23,17 +23,17 @@
api.getDocument(id || '').then((file) => {
if (!file) return;
file.json().then((fileContent) => {
activeFile.set(fileContent);
currentFile.set(fileContent);
});
});
</script>

<svelte:head>
<title>{$activeFile?.name || 'Editor'} | Akademia</title>
<title>{$currentFile?.name || 'Editor'} | Akademia</title>
</svelte:head>

<Workspace>
{#if $activeFile}
{#if $currentFile}
<div class="editor">
<Toolbar />
<FileEditor />
Expand Down
10 changes: 5 additions & 5 deletions src/routes/workspace/editor/Toolbar/MoreActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}
Expand Down Expand Up @@ -78,7 +78,7 @@

<Dialog.Dialog bind:open={isDeleteOpen}>
<Dialog.Content class="max-w-[23rem]">
<Dialog.Title>Er du sikker på, at du vil slette {$activeFile?.name}?</Dialog.Title>
<Dialog.Title>Er du sikker på, at du vil slette {$currentFile?.name}?</Dialog.Title>
<Dialog.Description
>Dette sletter filen permanent. Denne handling kan ikke fortrydes</Dialog.Description
>
Expand Down
12 changes: 6 additions & 6 deletions src/routes/workspace/editor/Toolbar/ShareDocument.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,7 +63,7 @@
let people: Member[] = [];
$: $activeFile && findMembers($activeFile);
$: $currentFile && findMembers($currentFile);
function findMembers(activeFile: FileInfo) {
people = [];
Expand Down Expand Up @@ -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);
});
}
Expand All @@ -121,7 +121,7 @@
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Header>
<Dialog.Title>Del '{$activeFile?.name || ''}'</Dialog.Title>
<Dialog.Title>Del '{$currentFile?.name || ''}'</Dialog.Title>
<Dialog.Description>
Kun personer, du inviterer, kan få adgang til dette dokument. Du kan ændre tilladelsen for
hver person.
Expand All @@ -130,7 +130,7 @@
<div class="flex space-x-2">
<Input
id="copy-link"
value="https://app.akademia.cc/workspace/editor?id={$activeFile?.id || 'failure'}"
value="https://app.akademia.cc/workspace/editor?id={$currentFile?.id || 'failure'}"
readonly
/>
<Button variant="secondary" class="shrink-0" on:click={() => copyLinkToClipboard()}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/workspace/home/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import ActiveFiles from './activeFiles/ActiveFiles.svelte';
import Workspace from './../Workspace.svelte';
import Calendar from './Calendar/Calendar.svelte';
import { activeFile } from '../../store';
import { currentFile } from '../../store';
activeFile.set(null);
currentFile.set(null);
</script>

<svelte:head>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/workspace/quickActions/SearchQ.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { CalendarPlus } from 'lucide-svelte';
import type ApiHandler from '@/api';
import randomName from '@/randomName';
import { activeFile } from '../../store';
import { currentFile } from '../../store';
let isSeaching = false;
const api = getContext('api') as ApiHandler;
Expand All @@ -33,7 +33,7 @@
function openFile(file: FileInfo) {
goto('editor?id=' + file.id);
isSeaching = false;
activeFile.set(file);
currentFile.set(file);
}
</script>

Expand Down

0 comments on commit 9c5d560

Please sign in to comment.