feat: tag bookmarks and sites, and browse the library by tag
This commit is contained in:
parent
5cd053c8a9
commit
b0b86ef5b1
13 changed files with 445 additions and 21 deletions
|
|
@ -45,6 +45,9 @@ class InternalActions {
|
|||
'unsubscribe' => _withUrl(args, _subscriptions.remove),
|
||||
'forget-page' => _withUrl(args, _db.forgetPage),
|
||||
'clear-history' => _clearHistory(),
|
||||
'add-tag' => _changeTag(args, add: true),
|
||||
'remove-tag' => _changeTag(args, add: false),
|
||||
'delete-tag' => _deleteTag(args['tag']),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
|
@ -64,6 +67,32 @@ class InternalActions {
|
|||
return true;
|
||||
}
|
||||
|
||||
/// Adds or removes one tag. An empty name is refused, so submitting an
|
||||
/// empty box does nothing.
|
||||
Future<bool> _changeTag(Map<String, String> args, {required bool add}) async {
|
||||
final kind = switch (args['kind']) {
|
||||
'bookmark' => TagKind.bookmark,
|
||||
'subscription' => TagKind.subscription,
|
||||
_ => null,
|
||||
};
|
||||
final url = args['url'];
|
||||
final tag = args['tag']?.trim();
|
||||
if (kind == null || url == null || url.isEmpty) return false;
|
||||
if (tag == null || tag.isEmpty) return false;
|
||||
if (add) {
|
||||
await _db.addTag(kind, url, tag);
|
||||
} else {
|
||||
await _db.removeTag(kind, url, tag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> _deleteTag(String? tag) async {
|
||||
if (tag == null || tag.isEmpty) return false;
|
||||
await _db.deleteTag(tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> _clearHistory() async {
|
||||
await _db.clearHistory();
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue