Fix flickering issues due to reconnecting loop

This commit is contained in:
2026-03-02 22:09:29 +08:00
parent 5713581992
commit 7115e2df05
8 changed files with 171 additions and 45 deletions
+13
View File
@@ -361,6 +361,19 @@ final ticketsQueryProvider = StateProvider<TicketQuery>(
(ref) => const TicketQuery(),
);
/// Derived provider that selects a single [Ticket] by ID from the tickets list.
///
/// Because [Ticket] implements `==`, this provider only notifies watchers when
/// the specific ticket's data actually changes — not when unrelated tickets in
/// the list are updated. Use this in detail screens to avoid full-list rebuilds.
final ticketByIdProvider = Provider.family<Ticket?, String>((ref, ticketId) {
return ref
.watch(ticketsProvider)
.valueOrNull
?.where((t) => t.id == ticketId)
.firstOrNull;
});
final ticketMessagesProvider =
StreamProvider.family<List<TicketMessage>, String>((ref, ticketId) {
final client = ref.watch(supabaseClientProvider);