diff --git a/stores/settingsStore.ts b/stores/settingsStore.ts index 0a20c37..b2e00b5 100644 --- a/stores/settingsStore.ts +++ b/stores/settingsStore.ts @@ -2,6 +2,7 @@ import { create } from "zustand"; import { SettingsManager } from "@/services/storage"; import { api, ServerConfig } from "@/services/api"; import { storageConfig } from "@/services/storageConfig"; +import AsyncStorage from "@react-native-async-storage/async-storage"; import Logger from "@/utils/Logger"; const logger = Logger.withTag('SettingsStore'); @@ -79,7 +80,8 @@ export const useSettingsStore = create((set, get) => ({ setVideoSource: (config) => set({ videoSource: config }), saveSettings: async () => { const { apiBaseUrl, m3uUrl, remoteInputEnabled, videoSource } = get(); - + const currentSettings = await SettingsManager.get() + const currentApiBaseUrl = currentSettings.apiBaseUrl; let processedApiBaseUrl = apiBaseUrl.trim(); if (processedApiBaseUrl.endsWith("/")) { processedApiBaseUrl = processedApiBaseUrl.slice(0, -1); @@ -105,6 +107,9 @@ export const useSettingsStore = create((set, get) => ({ remoteInputEnabled, videoSource, }); + if ( currentApiBaseUrl !== processedApiBaseUrl) { + await AsyncStorage.setItem('authCookies', ''); + } api.setBaseUrl(processedApiBaseUrl); // Also update the URL in the state so the input field shows the processed URL set({ isModalVisible: false, apiBaseUrl: processedApiBaseUrl });