mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-04 03:36:29 +08:00
@@ -2,6 +2,7 @@ import { create } from "zustand";
|
|||||||
import { SettingsManager } from "@/services/storage";
|
import { SettingsManager } from "@/services/storage";
|
||||||
import { api, ServerConfig } from "@/services/api";
|
import { api, ServerConfig } from "@/services/api";
|
||||||
import { storageConfig } from "@/services/storageConfig";
|
import { storageConfig } from "@/services/storageConfig";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import Logger from "@/utils/Logger";
|
import Logger from "@/utils/Logger";
|
||||||
|
|
||||||
const logger = Logger.withTag('SettingsStore');
|
const logger = Logger.withTag('SettingsStore');
|
||||||
@@ -79,7 +80,8 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
|
|||||||
setVideoSource: (config) => set({ videoSource: config }),
|
setVideoSource: (config) => set({ videoSource: config }),
|
||||||
saveSettings: async () => {
|
saveSettings: async () => {
|
||||||
const { apiBaseUrl, m3uUrl, remoteInputEnabled, videoSource } = get();
|
const { apiBaseUrl, m3uUrl, remoteInputEnabled, videoSource } = get();
|
||||||
|
const currentSettings = await SettingsManager.get()
|
||||||
|
const currentApiBaseUrl = currentSettings.apiBaseUrl;
|
||||||
let processedApiBaseUrl = apiBaseUrl.trim();
|
let processedApiBaseUrl = apiBaseUrl.trim();
|
||||||
if (processedApiBaseUrl.endsWith("/")) {
|
if (processedApiBaseUrl.endsWith("/")) {
|
||||||
processedApiBaseUrl = processedApiBaseUrl.slice(0, -1);
|
processedApiBaseUrl = processedApiBaseUrl.slice(0, -1);
|
||||||
@@ -105,6 +107,9 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
|
|||||||
remoteInputEnabled,
|
remoteInputEnabled,
|
||||||
videoSource,
|
videoSource,
|
||||||
});
|
});
|
||||||
|
if ( currentApiBaseUrl !== processedApiBaseUrl) {
|
||||||
|
await AsyncStorage.setItem('authCookies', '');
|
||||||
|
}
|
||||||
api.setBaseUrl(processedApiBaseUrl);
|
api.setBaseUrl(processedApiBaseUrl);
|
||||||
// Also update the URL in the state so the input field shows the processed URL
|
// Also update the URL in the state so the input field shows the processed URL
|
||||||
set({ isModalVisible: false, apiBaseUrl: processedApiBaseUrl });
|
set({ isModalVisible: false, apiBaseUrl: processedApiBaseUrl });
|
||||||
|
|||||||
Reference in New Issue
Block a user