From 5accc4e512e9bbff8d4303cb732edccaccd9b5a3 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 26 Apr 2026 12:40:27 +0000 Subject: feat(command-palette): add quick toggles, sync, and auth actions Adds 13 reactive quick toggles (24h time, animations, blur adult, cover modes, hover cover, schedule list, reverse sort, data saver, notifications, language, title format cycle, outbound link target cycle), three sync actions (push/pull/disable), and login/logout entries gated on auth state. Names reflect current state so the palette doubles as a status surface. --- src/lib/CommandPalette/authActions.ts | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/lib/CommandPalette/authActions.ts (limited to 'src/lib/CommandPalette/authActions.ts') diff --git a/src/lib/CommandPalette/authActions.ts b/src/lib/CommandPalette/authActions.ts new file mode 100644 index 00000000..c306eb34 --- /dev/null +++ b/src/lib/CommandPalette/authActions.ts @@ -0,0 +1,48 @@ +import { env } from "$env/dynamic/public"; +import root from "$lib/Utility/root"; +import localforage from "localforage"; +import type { CommandPaletteAction } from "./actions"; + +export const authActions = ( + user: string | undefined, +): CommandPaletteAction[] => { + if (user) + return [ + { + name: "Log Out", + url: "#", + preventDefault: true, + tags: ["auth", "sign", "out", "user"], + onClick: async () => { + await localforage.removeItem("identity"); + await localforage.removeItem("commit"); + + document.cookie = + "user=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; + + window.location.href = root("/api/authentication/log-out"); + }, + }, + ]; + + const loginUrl = `https://anilist.co/api/v2/oauth/authorize?client_id=${env.PUBLIC_ANILIST_CLIENT_ID}&redirect_uri=${env.PUBLIC_ANILIST_REDIRECT_URI}&response_type=code`; + + return [ + { + name: "Log In", + url: loginUrl, + preventDefault: true, + tags: ["auth", "sign", "in", "anilist"], + onClick: async () => { + await localforage.setItem( + "redirect", + window.location.origin + + window.location.pathname + + window.location.search, + ); + + window.location.href = loginUrl; + }, + }, + ]; +}; -- cgit v1.2.3