localstorage weg
This commit is contained in:
parent
1c1d758ab1
commit
5453691016
6 changed files with 4 additions and 29 deletions
4
frontend/svelte/package-lock.json
generated
4
frontend/svelte/package-lock.json
generated
|
|
@ -8,9 +8,7 @@
|
||||||
"name": "svelte_pages",
|
"name": "svelte_pages",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap-icons": "^1.9.1"
|
"bootstrap-icons": "^1.9.1",
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"nookies": "^2.5.2"
|
"nookies": "^2.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export const ssr = false;
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Note} from "../types";
|
import type {Note} from "../models/types";
|
||||||
import {bearerFetch, jwt} from "../models/PomeloUtils";
|
import {bearerFetch, jwt} from "../models/PomeloUtils";
|
||||||
import {onMount} from "svelte";
|
import {onMount} from "svelte";
|
||||||
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(notes);
|
console.log(notes);
|
||||||
sortNotesByDate();
|
|
||||||
window.localStorage.setItem("notes", JSON.stringify(notes));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads the Notes Listing
|
* Reloads the Notes Listing
|
||||||
|
|
@ -29,23 +27,6 @@
|
||||||
notes = notes.filter(i => i === i);
|
notes = notes.filter(i => i === i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the "notes" Array by the lastOpened Property of a Note
|
|
||||||
*/
|
|
||||||
function sortNotesByDate() {
|
|
||||||
notes.sort(function (x, y) {
|
|
||||||
if (x.lastOpened > y.lastOpened) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x.lastOpened < y.lastOpened) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the user a prompt to input the new title of the note and creates it if the title is valid
|
* Gives the user a prompt to input the new title of the note and creates it if the title is valid
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,9 +36,7 @@
|
||||||
if (newTitle != null && newTitle != '') {
|
if (newTitle != null && newTitle != '') {
|
||||||
addNote(newTitle);
|
addNote(newTitle);
|
||||||
console.log(notes)
|
console.log(notes)
|
||||||
sortNotesByDate();
|
|
||||||
reloadNotesListing();
|
reloadNotesListing();
|
||||||
window.localStorage.setItem("notes", JSON.stringify(notes));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +98,6 @@
|
||||||
* @param note The note the user clicked on
|
* @param note The note the user clicked on
|
||||||
*/
|
*/
|
||||||
function onNoteLiClick(note) {
|
function onNoteLiClick(note) {
|
||||||
window.localStorage.setItem("clickedNoteId", note.id);
|
|
||||||
window.location = "/editor";
|
window.location = "/editor";
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@ export async function load({params}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalid) {
|
if (invalid) {
|
||||||
window.location = "/login";
|
// window.location = "/login";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Note} from "../../types";
|
import type {Note} from "../../models/types";
|
||||||
|
|
||||||
let notes: Note[] = JSON.parse(window.localStorage.getItem("notes"));
|
let notes: Note[] = JSON.parse(window.localStorage.getItem("notes"));
|
||||||
const clickedNoteId = window.localStorage.getItem("clickedNoteId");
|
const clickedNoteId = window.localStorage.getItem("clickedNoteId");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue