Skip to content

Commit

Permalink
change more of file to document
Browse files Browse the repository at this point in the history
  • Loading branch information
Ell1ott committed Feb 28, 2024
1 parent 5240cc8 commit 0823ddd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/lib/api/apiStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export async function updateDocuments() {
if (!response) {
throw new Error('Could not update files due to no response');
}
const userDocumentsJson = await response.json();
console.log(userDocumentsJson);
const json = await response.json();
console.log(json);

fileStore.set(userDocumentsJson);
documentStore.set(json.map((docuemntInfo) => new DocumentInfo(docuemntInfo)));
console.log('updated files');
}
function getUserName(state: AuthorizerState): string {
Expand All @@ -73,7 +73,7 @@ export function updateUserInfo(state: AuthorizerState) {
}

// Explicitly specify the type of the store
export const fileStore = writable<FileInfo[]>([]);
export const documentStore = writable<DocumentInfo[]>([]);
export const assignmentStore = writable<Assignment[]>([]);

export const currentFile = writable<FileInfo | null>(null);
Expand Down
8 changes: 4 additions & 4 deletions src/routes/workspace/FileViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import { getContext, setContext } from 'svelte';
import SideBarElem from './SideBarElem.svelte';
import randomName from '$lib/randomName';
import { fileStore, type FileInfo } from '@/api/apiStore';
import { documentStore, type FileInfo } from '@/api/apiStore';
import { currentFile } from '../store';
const api = getContext('api') as ApiHandler;
export let files: FileInfo[] = $fileStore;
export let files: FileInfo[] = $documentStore;
$: files = $fileStore;
$: files = $documentStore;
</script>

<div class="cont br-2 float-panel">
Expand Down Expand Up @@ -40,7 +40,7 @@
return response.json();
});
currentFile.set(newFile);
fileStore.update((before) => [...before, newFile]);
documentStore.update((before) => [...before, newFile]);
}}
class="reset no-bg size-full"
>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/workspace/editor/Tiptap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Title } from '$lib/editor/extensions/title';
import { activeFile } from '../../store';
import { fileStore, type FileInfo } from '@/api/apiStore';
import { editor } from './editorStore';
import { editor } from './eddocumentStore';
let state: AuthorizerState;
Expand Down Expand Up @@ -129,7 +129,7 @@
}
console.log('steps', steps);
const typedLetter: string = steps[0].slice?.content?.content[0]?.text;
if (!typedLetter) return false;
ifdocumentStoreetter) return false;
const regex = /^[a-z]$/;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/workspace/editor/Toolbar/MoreActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { currentFile } from '../../../store';
import { getContext } from 'svelte';
import type ApiHandler from '@/api';
import { fileStore } from '@/api/apiStore';
import { documentStore } from '@/api/apiStore';
import { printUsingWindow } from '@/utils/printer';
let isDeleteOpen = false;
Expand All @@ -17,7 +17,7 @@
api.deleteDocument(id).then((response) => {
if (!response || response.status !== 200) return;
console.log(response);
fileStore.update((prev) => prev.filter((it) => it !== $currentFile));
documentStore.update((prev) => prev.filter((it) => it !== $currentFile));
currentFile.set(null);
});
isDeleteOpen = false;
Expand Down
10 changes: 5 additions & 5 deletions src/routes/workspace/home/activeFiles/ActiveFiles.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Document from './Document.svelte';
import Assignment from './Assignment.svelte';
import { Notebook, Target, File } from 'lucide-svelte';
import { fileStore, userInfo, assignmentStore } from '@/api/apiStore';
import { documentStore, userInfo, assignmentStore } from '@/api/apiStore';
console.log($assignmentStore);
</script>
Expand Down Expand Up @@ -36,10 +36,10 @@
Dokumenter
</h2>
<div class="filelist">
{#each $fileStore as f}
{#each $documentStore as f}
<Document name={f.name} id={f.id}></Document>
{/each}
{#if $fileStore.length == 0}
{#if $documentStore.length == 0}
<p class="">Der er ingen dokumenter</p>
{/if}
</div>
Expand All @@ -48,10 +48,10 @@
Noter
</h2>
<div class="filelist">
{#each $fileStore as f}
{#each $documentStore as f}
<Document name={f.name} id={f.id}></Document>
{/each}
{#if $fileStore.length == 0}
{#if $documentStore.length == 0}
<p class="">Der er ingen noter</p>
{/if}
</div>
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 @@ -5,7 +5,7 @@
import { getContext, setContext, tick } from 'svelte';
import { expoOut, quadIn, quadInOut, quadOut, sineInOut, sineOut } from 'svelte/easing';
import * as Command from '$lib/components/ui/command';
import { fileStore, type FileInfo } from '@/api/apiStore';
import { documentStore, type FileInfo } from '@/api/apiStore';
import { goto } from '$app/navigation';
import { BookPlus, File, FilePen, FilePlus2, NotebookPen, Plus } from 'lucide-svelte';
import { CalendarPlus } from 'lucide-svelte';
Expand Down Expand Up @@ -44,7 +44,7 @@
<Command.List>
<Command.Empty>Ingen resultater.</Command.Empty>
<Command.Group heading="Filer">
{#each $fileStore as file}
{#each $documentStore as file}
<Command.Item onSelect={() => openFile(file)}>
<File strokeWidth={1.5}></File>
{file.name}
Expand Down

0 comments on commit 0823ddd

Please sign in to comment.