diff --git a/stores/authStore.ts b/stores/authStore.ts index af2b1d3..c5bbdff 100644 --- a/stores/authStore.ts +++ b/stores/authStore.ts @@ -1,6 +1,7 @@ import { create } from "zustand"; import Cookies from "@react-native-cookies/cookies"; import { api } from "@/services/api"; +import { useSettingsStore } from "./settingsStore"; interface AuthState { isLoggedIn: boolean; @@ -17,6 +18,11 @@ const useAuthStore = create((set) => ({ showLoginModal: () => set({ isLoginModalVisible: true }), hideLoginModal: () => set({ isLoginModalVisible: false }), checkLoginStatus: async () => { + const { apiBaseUrl } = useSettingsStore.getState(); + if (!apiBaseUrl) { + set({ isLoggedIn: false, isLoginModalVisible: false }); + return; + } try { const { ok } = await api.login(); if (ok) { diff --git a/stores/settingsStore.ts b/stores/settingsStore.ts index ae786ef..3ad9c19 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 useHomeStore from './homeStore'; +import useAuthStore from './authStore'; interface SettingsState { @@ -29,7 +30,7 @@ interface SettingsState { export const useSettingsStore = create((set, get) => ({ apiBaseUrl: '', - m3uUrl: 'https://raw.githubusercontent.com/sjnhnp/adblock/refs/heads/main/filtered_http_only_valid.m3u', + m3uUrl: '', liveStreamSources: [], remoteInputEnabled: false, isModalVisible: false, @@ -75,6 +76,7 @@ export const useSettingsStore = create((set, get) => ({ api.setBaseUrl(apiBaseUrl); set({ isModalVisible: false }); useHomeStore.getState().fetchInitialData(); + useAuthStore.getState().checkLoginStatus(); }, showModal: () => set({ isModalVisible: true }), hideModal: () => set({ isModalVisible: false }),