Added archive and unarchive
This commit is contained in:
@@ -129,17 +129,18 @@ class SearchBookmarks extends _$SearchBookmarks {
|
||||
}
|
||||
|
||||
void archiveUnarchive(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread<SearchBookmarksModel>(
|
||||
final result = await BookmarkCommonFunctions.archiveUnarchive<SearchBookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
if (result != null) {
|
||||
state.bookmarks = state.bookmarks.map((b) => b.id == result.id ? result : b).toList();
|
||||
if (result == true) {
|
||||
// On this case the bookmark always will pass from unarchived to archived
|
||||
state.bookmarks = state.bookmarks.where((b) => b.id != bookmark.id).toList();
|
||||
ref.notifyListeners();
|
||||
ref
|
||||
.read(bookmarksProvider.notifier)
|
||||
.setBookmarks(ref.read(bookmarksProvider).bookmarks.map((b) => b.id == result.id ? result : b).toList());
|
||||
.setBookmarks(ref.read(bookmarksProvider).bookmarks.where((b) => b.id != bookmark.id).toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user