From 0ddd31ecd7b3935180ddbdae7d7963a3bc94d94f Mon Sep 17 00:00:00 2001 From: Nemo Date: Tue, 24 Mar 2026 12:25:40 +0800 Subject: [PATCH] fix: installation confirm - invalidate task cache + navigate back so status shows correctly --- app/(app)/tasks/[id].tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/(app)/tasks/[id].tsx b/app/(app)/tasks/[id].tsx index b64e4b9..1c0a3d1 100644 --- a/app/(app)/tasks/[id].tsx +++ b/app/(app)/tasks/[id].tsx @@ -74,8 +74,9 @@ export default function TicketDetailScreen() { }, onSuccess: () => { setShowStatusPicker(false); - refetch(); + qc.invalidateQueries({ queryKey: ['task', id] }); qc.invalidateQueries({ queryKey: ['tasks'] }); + refetch(); }, onError: () => Alert.alert('Error', 'Could not update status.'), }); @@ -136,12 +137,16 @@ export default function TicketDetailScreen() { setInstNotes(''); setCoords(null); - Alert.alert('Installation Complete! ✓', 'Ticket resolved, location updated, and activation ticket created.'); - refetch(); - qc.invalidateQueries({ queryKey: ['tasks'] }); - qc.invalidateQueries({ queryKey: ['client', ticket?.clientId] }); - qc.invalidateQueries({ queryKey: ['client-tickets', ticket?.clientId] }); - setActiveTab('comments'); + // Invalidate all caches then go back to list — avoids stale UI on current screen + await qc.invalidateQueries({ queryKey: ['tasks'] }); + await qc.invalidateQueries({ queryKey: ['task', id] }); + await qc.invalidateQueries({ queryKey: ['client', ticket?.clientId] }); + await qc.invalidateQueries({ queryKey: ['client-tickets', ticket?.clientId] }); + Alert.alert( + 'Installation Complete! ✓', + 'Ticket resolved, location recorded, and activation ticket created.', + [{ text: 'OK', onPress: () => router.back() }] + ); } catch { Alert.alert('Error', 'Could not confirm installation. Please try again.'); } finally {