fix(app): skip agent list refresh when screen is unfocused
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useMemo, useState, useCallback, useEffect } from "react";
|
import { useMemo, useState, useCallback, useEffect } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
import { useIsFocused } from "@react-navigation/native";
|
||||||
import { StyleSheet } from "react-native-unistyles";
|
import { StyleSheet } from "react-native-unistyles";
|
||||||
import { BackHeader } from "@/components/headers/back-header";
|
import { BackHeader } from "@/components/headers/back-header";
|
||||||
import { AgentList } from "@/components/agent-list";
|
import { AgentList } from "@/components/agent-list";
|
||||||
@@ -8,6 +9,16 @@ import { router } from "expo-router";
|
|||||||
import { buildHostRootRoute } from "@/utils/host-routes";
|
import { buildHostRootRoute } from "@/utils/host-routes";
|
||||||
|
|
||||||
export function AgentsScreen({ serverId }: { serverId: string }) {
|
export function AgentsScreen({ serverId }: { serverId: string }) {
|
||||||
|
const isFocused = useIsFocused();
|
||||||
|
|
||||||
|
if (!isFocused) {
|
||||||
|
return <View style={styles.container} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <AgentsScreenContent serverId={serverId} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function AgentsScreenContent({ serverId }: { serverId: string }) {
|
||||||
const { agents, isRevalidating, refreshAll } = useAllAgentsList({
|
const { agents, isRevalidating, refreshAll } = useAllAgentsList({
|
||||||
serverId,
|
serverId,
|
||||||
includeArchived: true,
|
includeArchived: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user