From 952917d4158e89ea11939cf3ce7c709331344526 Mon Sep 17 00:00:00 2001 From: j-weissen Date: Tue, 18 Oct 2022 09:00:19 +0200 Subject: [PATCH] added comments, fixed repo error --- .../models/repos/note/StrapiNoteRepository.ts | 1 + .../svelte/src/routes/editor/+page.svelte | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/svelte/src/models/repos/note/StrapiNoteRepository.ts b/frontend/svelte/src/models/repos/note/StrapiNoteRepository.ts index 47370e9..4043bbf 100644 --- a/frontend/svelte/src/models/repos/note/StrapiNoteRepository.ts +++ b/frontend/svelte/src/models/repos/note/StrapiNoteRepository.ts @@ -79,6 +79,7 @@ export class StrapiNoteRepository implements NoteRepository { } static getAuthorizationHeader() { + // @ts-ignore const jwt = parseCookies('/').jwt; return `bearer ${jwt}` } diff --git a/frontend/svelte/src/routes/editor/+page.svelte b/frontend/svelte/src/routes/editor/+page.svelte index b9a3892..3c258e3 100644 --- a/frontend/svelte/src/routes/editor/+page.svelte +++ b/frontend/svelte/src/routes/editor/+page.svelte @@ -5,6 +5,7 @@ let noteRepo: StrapiNoteRepository; let currentNote: Note; + onMount(async () => { noteRepo = StrapiNoteRepository.getInstance(); try { @@ -16,19 +17,24 @@ content = (currentNote).content; }) - function save() { + /** + * saves the currently opened Note and returns to listing + */ + function saveAndQuit() { noteRepo.updateNote(currentNote.id, { "title": title, - "content": content + "content": content, }) returnToListing(); } + /** + * redirects to listing + */ function returnToListing() { window.location = "/"; } - export let title: string, content: string; @@ -44,10 +50,10 @@

{title}

-
+
- +
@@ -55,16 +61,20 @@