Added share and unshare bookmarks

This commit is contained in:
Juan Gilsanz Polo
2024-02-27 18:20:00 +01:00
parent 5ab3b59152
commit 3f298cc22d
17 changed files with 390 additions and 9 deletions

View File

@@ -147,4 +147,20 @@ class SearchBookmarks extends _$SearchBookmarks {
.setBookmarks(ref.read(bookmarksProvider).bookmarks.where((b) => b.id != bookmark.id).toList());
}
}
void shareUnshare(Bookmark bookmark) async {
final result = await BookmarkCommonFunctions.shareUnshare<SearchBookmarksModel>(
scaffoldMessengerKey: ScaffoldMessengerKeys.search,
ref: ref,
bookmark: bookmark,
apiClient: ref.read(apiClientProvider)!,
);
if (result != null) {
state.bookmarks = state.bookmarks.map((b) => b.id == result.id ? result : b).toList();
ref.notifyListeners();
ref
.read(bookmarksProvider.notifier)
.setBookmarks(ref.read(bookmarksProvider).bookmarks.map((b) => b.id == result.id ? result : b).toList());
}
}
}