From d3d60f55ab849a108dfb8905d9f6a18454ddf5f7 Mon Sep 17 00:00:00 2001 From: Dzianis Vauchok <2119348+dzianisv@users.noreply.github.com> Date: Tue, 26 May 2026 07:38:32 +0000 Subject: [PATCH] fix: reload sessions on tab focus instead of only on client change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sessions screen was using useEffect with [client] to load sessions, which only fired when the client object reference changed. If the app was backgrounded and later foregrounded (common scenario on mobile), the session list was never refreshed, showing stale data. Replaced with useFocusEffect from expo-router so sessions are reloaded every time the sessions tab is focused — including: - Initial mount - Coming back from background - Switching tabs and returning --- app/(tabs)/index.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index eefa6e1..3fd5cf2 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -1,4 +1,4 @@ -import { useEffect, useCallback, useState, useRef } from "react" +import { useCallback, useState, useRef } from "react" import { View, Text, @@ -14,7 +14,7 @@ import { KeyboardAvoidingView, Platform, } from "react-native" -import { router } from "expo-router" +import { router, useFocusEffect } from "expo-router" import { Ionicons } from "@expo/vector-icons" import { useSessions } from "../../src/stores/sessions" import { useConnections } from "../../src/stores/connections" @@ -135,12 +135,14 @@ export default function SessionsScreen() { [switchDirectory, loadSessions, refreshProject], ) - useEffect(() => { - if (client) { - loadSessions() - refreshProject() - } - }, [client]) + useFocusEffect( + useCallback(() => { + if (client) { + loadSessions() + refreshProject() + } + }, [client, loadSessions, refreshProject]), + ) const onRefresh = useCallback(async () => { setRefreshing(true)