add bookmarks view

This commit is contained in:
2026-06-02 17:58:06 +03:00
parent edfa2e232f
commit 2c8bc6dca8
15 changed files with 223 additions and 46 deletions

View File

@@ -7,9 +7,9 @@ async function getHTML(endpoint, options = {}) {
const params = new URLSearchParams(query);
const res = await fetch(`${endpoint}?${params}`, options);
if (!res.ok) {
console.error(res);
}
// if (!res.ok) {
// console.error(res);
// }
return { body: await res.text(), status: res.status };
}
@@ -81,7 +81,7 @@ export async function bookmarkMenuSubmit(ev, _, el) {
const status = (await getHTML(url, options)).status;
if (status !== 204) {
b.trigger('bookmarkMenuShowError');
b.send({ status: status }, 'bookmarkMenuShowError');
return;
}
@@ -99,11 +99,17 @@ export function bookmarkMenuResetSavedButton(_, __, el) {
el.value = 'Save';
}
export function bookmarkMenuShowError(_, __, el) {
export function bookmarkMenuShowError(payload, _, el) {
if (el === undefined) {
return;
}
if (payload.status === 404) {
el.innerText = 'This thread or post no longer exists. Please refresh the page.';
} else {
el.innerText = 'Something went wrong. Try again later.';
}
if (el.classList.contains('hidden')) {
el.classList.remove('hidden');
setTimeout(() => { b.trigger('bookmarkMenuHideError') }, 4000);