1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-21 14:47:41 +01:00

Merge pull request #643 from qtchaos/proxy-syncing

Implement Worker URLs syncing with backend
This commit is contained in:
mrjvs 2024-01-01 19:08:52 +01:00 committed by GitHub
commit 27ff4529fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 2 deletions

View file

@ -7,12 +7,14 @@ export interface SettingsInput {
applicationLanguage?: string;
applicationTheme?: string | null;
defaultSubtitleLanguage?: string;
proxyUrls?: string[] | null;
}
export interface SettingsResponse {
applicationTheme?: string | null;
applicationLanguage?: string | null;
defaultSubtitleLanguage?: string | null;
proxyUrls?: string[] | null;
}
export function updateSettings(

View file

@ -20,6 +20,7 @@ export function useAuthData() {
const loggedIn = !!useAuthStore((s) => s.account);
const setAccount = useAuthStore((s) => s.setAccount);
const removeAccount = useAuthStore((s) => s.removeAccount);
const setProxySet = useAuthStore((s) => s.setProxySet);
const clearBookmarks = useBookmarkStore((s) => s.clear);
const clearProgress = useProgressStore((s) => s.clear);
const setTheme = useThemeStore((s) => s.setTheme);
@ -80,6 +81,10 @@ export function useAuthData() {
if (settings.applicationTheme) {
setTheme(settings.applicationTheme);
}
if (settings.proxyUrls) {
setProxySet(settings.proxyUrls);
}
},
[
replaceBookmarks,
@ -87,6 +92,7 @@ export function useAuthData() {
setAppLanguage,
importSubtitleLanguage,
setTheme,
setProxySet,
],
);

View file

@ -140,10 +140,15 @@ export function SettingsPage() {
const saveChanges = useCallback(async () => {
if (account) {
if (state.appLanguage.changed || state.theme.changed) {
if (
state.appLanguage.changed ||
state.theme.changed ||
state.proxyUrls.changed
) {
await updateSettings(backendUrl, account, {
applicationLanguage: state.appLanguage.state,
applicationTheme: state.theme.state,
proxyUrls: state.proxyUrls.state?.filter((v) => v !== "") ?? null,
});
}
if (state.deviceName.changed) {
@ -166,7 +171,7 @@ export function SettingsPage() {
setAppLanguage(state.appLanguage.state);
setTheme(state.theme.state);
setSubStyling(state.subtitleStyling.state);
setProxySet(state.proxyUrls.state);
setProxySet(state.proxyUrls.state?.filter((v) => v !== "") ?? null);
if (state.profile.state) {
updateProfile(state.profile.state);

View file

@ -74,6 +74,7 @@ export function VerifyPassphrase(props: VerifyPassphraseProps) {
applicationLanguage,
defaultSubtitleLanguage: defaultSubtitleLanguage ?? undefined,
applicationTheme: applicationTheme ?? undefined,
proxyUrls: undefined,
});
await restore(account);