From 990745eba97fb97462e9b4e968f12a0360863324 Mon Sep 17 00:00:00 2001 From: zimplexing Date: Fri, 18 Jul 2025 12:19:29 +0800 Subject: [PATCH] feat: modify LoginModal to conditionally handle visibility based on pathname, preventing display on settings page --- components/LoginModal.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/LoginModal.tsx b/components/LoginModal.tsx index 6c813a2..fed6838 100644 --- a/components/LoginModal.tsx +++ b/components/LoginModal.tsx @@ -1,5 +1,6 @@ import React, { useState, useRef, useEffect } from "react"; import { Modal, View, TextInput, StyleSheet, ActivityIndicator, useTVEventHandler } from "react-native"; +import { usePathname } from "expo-router"; import Toast from "react-native-toast-message"; import useAuthStore from "@/stores/authStore"; import { useSettingsStore } from "@/stores/settingsStore"; @@ -20,9 +21,11 @@ const LoginModal = () => { const passwordInputRef = useRef(null); const loginButtonRef = useRef(null); const [focused, setFocused] = useState("username"); + const pathname = usePathname(); + const isSettingsPage = pathname.includes("settings"); const tvEventHandler = (evt: any) => { - if (!evt || !isLoginModalVisible) { + if (!evt || !isLoginModalVisible || isSettingsPage) { return; } @@ -48,7 +51,7 @@ const LoginModal = () => { useTVEventHandler(tvEventHandler); useEffect(() => { - if (isLoginModalVisible) { + if (isLoginModalVisible && !isSettingsPage) { const isUsernameVisible = serverConfig?.StorageType !== "localstorage"; setTimeout(() => { if (isUsernameVisible) { @@ -58,7 +61,7 @@ const LoginModal = () => { } }, 200); } - }, [isLoginModalVisible, serverConfig]); + }, [isLoginModalVisible, serverConfig, isSettingsPage]); const handleLogin = async () => { const isLocalStorage = serverConfig?.StorageType === "localstorage"; @@ -83,7 +86,12 @@ const LoginModal = () => { }; return ( - + 需要登录