mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-19 11:22:04 +00:00
basic febbox + backend handling
preparing for backend v2
This commit is contained in:
parent
2ca64a6b17
commit
48b5ed7155
3 changed files with 19 additions and 2 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue