feat: Improve task data fetching by clearing grouped tasks on new load and preventing duplicates
This commit is contained in:
parent
ac7a75c92f
commit
82c2cc3c58
@ -134,11 +134,24 @@ class DailyTaskController extends GetxController {
|
||||
);
|
||||
|
||||
if (response != null && response.isNotEmpty) {
|
||||
if (!isLoadMore) {
|
||||
groupedDailyTasks.clear();
|
||||
}
|
||||
|
||||
for (var task in response) {
|
||||
final assignmentDateKey =
|
||||
task.assignmentDate.toIso8601String().split('T')[0];
|
||||
groupedDailyTasks.putIfAbsent(assignmentDateKey, () => []).add(task);
|
||||
|
||||
// Initialize list if not present
|
||||
groupedDailyTasks.putIfAbsent(assignmentDateKey, () => []);
|
||||
|
||||
// Only add task if it doesn't already exist (avoid duplicates)
|
||||
if (!groupedDailyTasks[assignmentDateKey]!
|
||||
.any((t) => t.id == task.id)) {
|
||||
groupedDailyTasks[assignmentDateKey]!.add(task);
|
||||
}
|
||||
}
|
||||
|
||||
dailyTasks = groupedDailyTasks.values.expand((list) => list).toList();
|
||||
currentPage = pageNumber;
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user