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
+24
View File
@@ -526,6 +526,30 @@ List<Map<String, dynamic>> _processTasksInIsolate(
/// Provider for task query parameters.
final tasksQueryProvider = StateProvider<TaskQuery>((ref) => const TaskQuery());
/// Derived provider that selects a single [Task] by ID from the tasks list.
///
/// Because [Task] implements `==`, this provider only notifies watchers when
/// the specific task's data actually changes — not when unrelated tasks in the
/// list are updated. Use this in detail screens to avoid full-list rebuilds.
final taskByIdProvider = Provider.family<Task?, String>((ref, taskId) {
return ref
.watch(tasksProvider)
.valueOrNull
?.where((t) => t.id == taskId)
.firstOrNull;
});
/// Derived provider that selects a [Task] linked to a given ticket ID.
///
/// Returns the first task whose `ticketId` matches [ticketId], or null.
final taskByTicketIdProvider = Provider.family<Task?, String>((ref, ticketId) {
return ref
.watch(tasksProvider)
.valueOrNull
?.where((t) => t.ticketId == ticketId)
.firstOrNull;
});
final taskAssignmentsProvider = StreamProvider<List<TaskAssignment>>((ref) {
final client = ref.watch(supabaseClientProvider);