basic febbox + backend handling

preparing for backend v2
This commit is contained in:
Pas 2025-04-13 15:36:28 -06:00
parent 2ca64a6b17
commit 48b5ed7155
3 changed files with 19 additions and 2 deletions

View file

@ -8,6 +8,7 @@ export interface SettingsInput {
applicationTheme?: string | null;
defaultSubtitleLanguage?: string;
proxyUrls?: string[] | null;
febboxKey?: string | null;
}
export interface SettingsResponse {
@ -15,6 +16,7 @@ export interface SettingsResponse {
applicationLanguage?: string | null;
defaultSubtitleLanguage?: string | null;
proxyUrls?: string[] | null;
febboxKey?: string | null;
}
export function updateSettings(

View file

@ -28,6 +28,7 @@ export function useAuthData() {
const importSubtitleLanguage = useSubtitleStore(
(s) => s.importSubtitleLanguage,
);
const setFebboxToken = useAuthStore((s) => s.setFebboxToken);
const replaceBookmarks = useBookmarkStore((s) => s.replaceBookmarks);
const replaceItems = useProgressStore((s) => s.replaceItems);
@ -57,7 +58,8 @@ export function useAuthData() {
removeAccount();
clearBookmarks();
clearProgress();
}, [removeAccount, clearBookmarks, clearProgress]);
setFebboxToken(null);
}, [removeAccount, clearBookmarks, clearProgress, setFebboxToken]);
const syncData = useCallback(
async (

View file

@ -9,7 +9,7 @@ import {
encryptData,
} from "@/backend/accounts/crypto";
import { getSessions, updateSession } from "@/backend/accounts/sessions";
import { updateSettings } from "@/backend/accounts/settings";
import { getSettings, updateSettings } from "@/backend/accounts/settings";
import { editUser } from "@/backend/accounts/user";
import { getAllProviders } from "@/backend/providers/providers";
import { Button } from "@/components/buttons/Button";
@ -175,6 +175,18 @@ export function SettingsPage() {
const { logout } = useAuth();
const user = useAuthStore();
useEffect(() => {
const loadSettings = async () => {
if (account && backendUrl) {
const settings = await getSettings(backendUrl, account);
if (settings.febboxKey) {
setFebboxToken(settings.febboxKey);
}
}
};
loadSettings();
}, [account, backendUrl, setFebboxToken]);
const state = useSettingsState(
activeTheme,
appLanguage,
@ -241,6 +253,7 @@ export function SettingsPage() {
applicationLanguage: state.appLanguage.state,
applicationTheme: state.theme.state,
proxyUrls: state.proxyUrls.state?.filter((v) => v !== "") ?? null,
febboxKey: state.febboxToken.state,
});
}
if (state.deviceName.changed) {