Skip to content

Commit

Permalink
Corrected the logic for queried tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
BrawlerXull committed May 15, 2024
1 parent 71aae43 commit 81dcf76
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lib/model/storage/storage_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,22 @@ class _StorageWidgetState extends State<StorageWidget> {

void _refreshTasks() {
if (pendingFilter) {
queriedTasks = storage.data.pendingData().where((task) => task.status == 'pending').toList();
queriedTasks = storage.data
.pendingData()
.where((task) => task.status == 'pending')
.toList();
} else {
queriedTasks = storage.data.completedData();
}

if (waitingFilter) {
var currentTime = DateTime.now();
queriedTasks = queriedTasks.where((task) => task.wait != null && task.wait!.isAfter(currentTime)).toList();
queriedTasks = queriedTasks
.where((task) =>
task.wait == null ||
task.wait!.isBefore(currentTime) ||
task.wait!.isAtSameMomentAs(currentTime))
.toList();
}

if (projectFilter.isNotEmpty) {
Expand All @@ -131,11 +139,13 @@ class _StorageWidgetState extends State<StorageWidget> {
if (selectedTags.isEmpty) {
return true;
}
return selectedTags
.any((tag) => (tag.startsWith('+')) ? tags.contains(tag.substring(1)) : !tags.contains(tag.substring(1)));
return selectedTags.any((tag) => (tag.startsWith('+'))
? tags.contains(tag.substring(1))
: !tags.contains(tag.substring(1)));
} else {
return selectedTags
.every((tag) => (tag.startsWith('+')) ? tags.contains(tag.substring(1)) : !tags.contains(tag.substring(1)));
return selectedTags.every((tag) => (tag.startsWith('+'))
? tags.contains(tag.substring(1))
: !tags.contains(tag.substring(1)));
}
}).toList();

Expand All @@ -156,7 +166,8 @@ class _StorageWidgetState extends State<StorageWidget> {
searchedTasks = searchedTasks
.where((task) =>
task.description.contains(searchTerm) ||
(task.annotations?.asList() ?? []).any((annotation) => annotation.description.contains(searchTerm)))
(task.annotations?.asList() ?? []).any(
(annotation) => annotation.description.contains(searchTerm)))
.toList();
}
pendingTags = _pendingTags();
Expand Down Expand Up @@ -537,7 +548,8 @@ class InheritedStorage extends InheritedModel<String> {
}

@override
bool updateShouldNotifyDependent(InheritedStorage oldWidget, Set<String> dependencies) {
bool updateShouldNotifyDependent(
InheritedStorage oldWidget, Set<String> dependencies) {
return true;
}
}

0 comments on commit 81dcf76

Please sign in to comment.