deleteBookmarkByTarget method
- required BookmarkKind kind,
- required String targetId,
Removes the bookmark for the given target if one exists. Returns
true if a row was deleted, false if no bookmark existed.
Convenience for toggle UIs that don't want to fetch first.
Implementation
Future<bool> deleteBookmarkByTarget({
required BookmarkKind kind,
required String targetId,
}) async {
final column = switch (kind) {
BookmarkKind.topic => 'topic_id',
BookmarkKind.chunk => 'chunk_id',
BookmarkKind.session => 'session_id',
};
final deleted = await _client
.from('user_bookmarks')
.delete()
.eq('kind', BookmarkModel.kindToString(kind))
.eq(column, targetId)
.select();
return (deleted as List).isNotEmpty;
}