refactored more error code

This commit is contained in:
2025-09-26 21:10:19 +02:00
parent e3b735bb7b
commit 2463f92b1c
23 changed files with 111 additions and 173 deletions

View File

@@ -3,6 +3,7 @@
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js';
import { user } from '../../user.svelte.js';
@@ -10,7 +11,6 @@
import List from './List.svelte';
let authors = $state(null);
let error = $state(null);
let note = $state({source:null,rendered:null});
let notes = $state(null);
const router = useTinyRouter();
@@ -27,10 +27,10 @@
method : 'DELETE'
});
if (resp.ok) {
error = false;
yikes();
delete notes[nid];
} else {
error = await resp.text();
error(resp);
}
}
@@ -46,7 +46,7 @@
notes = Object.values(data.notes).sort((a, b) => a.id - b.id);
authors = data.authors;
} else {
error = await resp.text();
error(resp);
}
}
@@ -61,12 +61,12 @@
let newNote = await resp.json();
authors[user.id] = user;
notes.push(newNote);
error = null;
yikes();
note.source = null;
note.rendered = null;
return true;
} else {
error = await resp.text();
error(resp);
return false;
}
}
@@ -79,10 +79,10 @@
body : src
});
if (resp.ok) {
error = false;
yikes();
return true;
} else {
error = await resp.text();
error(resp);
return true;
}
}
@@ -90,9 +90,6 @@
onMount(load);
</script>
{#if error}
<span class="error">{error}</span>
{/if}
<List {authors} {module} {notes} />
<div class="editor">
<Editor simple={true} bind:value={note} onSet={saveNote} />