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 {