fix: resolve syntax error in watchlist.ts

This commit is contained in:
2026-06-16 13:59:55 +02:00
committed by Milas Holsting
parent 262dc6e406
commit 0cd47ab0fe

View File

@@ -189,15 +189,14 @@ const toggleWatchlist = async (
if (!response.ok) { if (!response.ok) {
throw new Error("not ok"); throw new Error("not ok");
} }
} catch (error) {
toast(optimisticNext ? `Added ${title} to watchlist` : `Removed ${title} from watchlist`);
} catch {
rollback(); rollback();
toast("Failed to update watchlist"); toast("Failed to update watchlist");
console.error("failed to update watchlist:", error);
throw error;
} finally { } finally {
watchlistStore.settle(id); watchlistStore.settle(id);
setBusy(id, false); setBusy(id, false);
syncIconsForId(id);
syncRemoveButtonVisibility(id); syncRemoveButtonVisibility(id);
} }
}; };
@@ -412,9 +411,11 @@ const updateWatchlist = async (
closeClosestDropdown(source); closeClosestDropdown(source);
toast(`Marked ${title} as ${display}`); toast(`Marked ${title} as ${display}`);
} catch { } catch (error) {
rollback(); rollback();
toast("Failed to update watchlist"); toast("Failed to update watchlist");
console.error("failed to update watchlist:", error);
throw error;
} finally { } finally {
watchlistStore.settle(id); watchlistStore.settle(id);
setBusy(id, false); setBusy(id, false);
@@ -451,9 +452,11 @@ const removeWatchlist = async (id: number, title: string, source: HTMLElement):
window.setTimeout(() => window.location.reload(), 50); window.setTimeout(() => window.location.reload(), 50);
} }
} }
} catch { } catch (error) {
rollback(); rollback();
toast("Failed to update watchlist"); toast("Failed to update watchlist");
console.error("failed to update watchlist:", error);
throw error;
} finally { } finally {
watchlistStore.settle(id); watchlistStore.settle(id);
setBusy(id, false); setBusy(id, false);
@@ -546,7 +549,8 @@ onReady(() => {
let parsed: unknown = null; let parsed: unknown = null;
try { try {
parsed = JSON.parse(raw); parsed = JSON.parse(raw);
} catch { } catch (error) {
console.error("Failed to parse watchlist IDs JSON:", error);
parsed = null; parsed = null;
} }
const ids = Array.isArray(parsed) const ids = Array.isArray(parsed)