mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-30 16:17:41 +01:00
Add Worker URLs syncing with backend
This commit is contained in:
parent
5ba66db7b4
commit
d016137989
4 changed files with 16 additions and 2 deletions
|
@ -7,12 +7,14 @@ export interface SettingsInput {
|
||||||
applicationLanguage?: string;
|
applicationLanguage?: string;
|
||||||
applicationTheme?: string | null;
|
applicationTheme?: string | null;
|
||||||
defaultSubtitleLanguage?: string;
|
defaultSubtitleLanguage?: string;
|
||||||
|
proxyUrls?: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SettingsResponse {
|
export interface SettingsResponse {
|
||||||
applicationTheme?: string | null;
|
applicationTheme?: string | null;
|
||||||
applicationLanguage?: string | null;
|
applicationLanguage?: string | null;
|
||||||
defaultSubtitleLanguage?: string | null;
|
defaultSubtitleLanguage?: string | null;
|
||||||
|
proxyUrls?: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateSettings(
|
export function updateSettings(
|
||||||
|
|
|
@ -20,6 +20,7 @@ export function useAuthData() {
|
||||||
const loggedIn = !!useAuthStore((s) => s.account);
|
const loggedIn = !!useAuthStore((s) => s.account);
|
||||||
const setAccount = useAuthStore((s) => s.setAccount);
|
const setAccount = useAuthStore((s) => s.setAccount);
|
||||||
const removeAccount = useAuthStore((s) => s.removeAccount);
|
const removeAccount = useAuthStore((s) => s.removeAccount);
|
||||||
|
const setProxySet = useAuthStore((s) => s.setProxySet);
|
||||||
const clearBookmarks = useBookmarkStore((s) => s.clear);
|
const clearBookmarks = useBookmarkStore((s) => s.clear);
|
||||||
const clearProgress = useProgressStore((s) => s.clear);
|
const clearProgress = useProgressStore((s) => s.clear);
|
||||||
const setTheme = useThemeStore((s) => s.setTheme);
|
const setTheme = useThemeStore((s) => s.setTheme);
|
||||||
|
@ -80,6 +81,10 @@ export function useAuthData() {
|
||||||
if (settings.applicationTheme) {
|
if (settings.applicationTheme) {
|
||||||
setTheme(settings.applicationTheme);
|
setTheme(settings.applicationTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.proxyUrls) {
|
||||||
|
setProxySet(settings.proxyUrls);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
replaceBookmarks,
|
replaceBookmarks,
|
||||||
|
@ -87,6 +92,7 @@ export function useAuthData() {
|
||||||
setAppLanguage,
|
setAppLanguage,
|
||||||
importSubtitleLanguage,
|
importSubtitleLanguage,
|
||||||
setTheme,
|
setTheme,
|
||||||
|
setProxySet,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -140,10 +140,15 @@ export function SettingsPage() {
|
||||||
|
|
||||||
const saveChanges = useCallback(async () => {
|
const saveChanges = useCallback(async () => {
|
||||||
if (account) {
|
if (account) {
|
||||||
if (state.appLanguage.changed || state.theme.changed) {
|
if (
|
||||||
|
state.appLanguage.changed ||
|
||||||
|
state.theme.changed ||
|
||||||
|
state.proxyUrls.changed
|
||||||
|
) {
|
||||||
await updateSettings(backendUrl, account, {
|
await updateSettings(backendUrl, account, {
|
||||||
applicationLanguage: state.appLanguage.state,
|
applicationLanguage: state.appLanguage.state,
|
||||||
applicationTheme: state.theme.state,
|
applicationTheme: state.theme.state,
|
||||||
|
proxyUrls: state.proxyUrls.state?.filter((v) => v !== "") ?? null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (state.deviceName.changed) {
|
if (state.deviceName.changed) {
|
||||||
|
@ -166,7 +171,7 @@ export function SettingsPage() {
|
||||||
setAppLanguage(state.appLanguage.state);
|
setAppLanguage(state.appLanguage.state);
|
||||||
setTheme(state.theme.state);
|
setTheme(state.theme.state);
|
||||||
setSubStyling(state.subtitleStyling.state);
|
setSubStyling(state.subtitleStyling.state);
|
||||||
setProxySet(state.proxyUrls.state);
|
setProxySet(state.proxyUrls.state?.filter((v) => v !== "") ?? null);
|
||||||
|
|
||||||
if (state.profile.state) {
|
if (state.profile.state) {
|
||||||
updateProfile(state.profile.state);
|
updateProfile(state.profile.state);
|
||||||
|
|
|
@ -74,6 +74,7 @@ export function VerifyPassphrase(props: VerifyPassphraseProps) {
|
||||||
applicationLanguage,
|
applicationLanguage,
|
||||||
defaultSubtitleLanguage: defaultSubtitleLanguage ?? undefined,
|
defaultSubtitleLanguage: defaultSubtitleLanguage ?? undefined,
|
||||||
applicationTheme: applicationTheme ?? undefined,
|
applicationTheme: applicationTheme ?? undefined,
|
||||||
|
proxyUrls: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
await restore(account);
|
await restore(account);
|
||||||
|
|
Loading…
Reference in a new issue