mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-04 03:36:29 +08:00
fix(remote-input): resolve cross-page interference between settings and search pages
- Add targetPage field to remoteControlStore for message routing - Update settings page to filter messages by target page - Update search page to filter messages and pass target context - Add clearMessage method to prevent duplicate message handling - Ensure remote input only affects intended target page
This commit is contained in:
@@ -26,7 +26,7 @@ export default function SearchScreen() {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const textInputRef = useRef<TextInput>(null);
|
||||
const [isInputFocused, setIsInputFocused] = useState(false);
|
||||
const { showModal: showRemoteModal, lastMessage } = useRemoteControlStore();
|
||||
const { showModal: showRemoteModal, lastMessage, targetPage, clearMessage } = useRemoteControlStore();
|
||||
const { remoteInputEnabled } = useSettingsStore();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -36,14 +36,15 @@ export default function SearchScreen() {
|
||||
const { deviceType, spacing } = responsiveConfig;
|
||||
|
||||
useEffect(() => {
|
||||
if (lastMessage) {
|
||||
if (lastMessage && targetPage === 'search') {
|
||||
console.log("Received remote input:", lastMessage);
|
||||
const realMessage = lastMessage.split("_")[0];
|
||||
setKeyword(realMessage);
|
||||
handleSearch(realMessage);
|
||||
clearMessage(); // Clear the message after processing
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [lastMessage]);
|
||||
}, [lastMessage, targetPage]);
|
||||
|
||||
// useEffect(() => {
|
||||
// // Focus the text input when the screen loads
|
||||
@@ -87,10 +88,10 @@ export default function SearchScreen() {
|
||||
]);
|
||||
return;
|
||||
}
|
||||
showRemoteModal();
|
||||
showRemoteModal('search');
|
||||
};
|
||||
|
||||
const renderItem = ({ item, index }: { item: SearchResult; index: number }) => (
|
||||
const renderItem = ({ item }: { item: SearchResult; index: number }) => (
|
||||
<VideoCard
|
||||
id={item.id.toString()}
|
||||
source={item.source}
|
||||
|
||||
@@ -22,7 +22,7 @@ import { DeviceUtils } from "@/utils/DeviceUtils";
|
||||
|
||||
export default function SettingsScreen() {
|
||||
const { loadSettings, saveSettings, setApiBaseUrl, setM3uUrl } = useSettingsStore();
|
||||
const { lastMessage } = useRemoteControlStore();
|
||||
const { lastMessage, targetPage, clearMessage } = useRemoteControlStore();
|
||||
const backgroundColor = useThemeColor({}, "background");
|
||||
|
||||
// 响应式布局配置
|
||||
@@ -44,12 +44,13 @@ export default function SettingsScreen() {
|
||||
}, [loadSettings]);
|
||||
|
||||
useEffect(() => {
|
||||
if (lastMessage) {
|
||||
if (lastMessage && !targetPage) {
|
||||
const realMessage = lastMessage.split("_")[0];
|
||||
handleRemoteInput(realMessage);
|
||||
clearMessage(); // Clear the message after processing
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [lastMessage]);
|
||||
}, [lastMessage, targetPage]);
|
||||
|
||||
const handleRemoteInput = (message: string) => {
|
||||
// Handle remote input based on currently focused section
|
||||
|
||||
Reference in New Issue
Block a user