feat: search, filter and act on items from the library pages
This commit is contained in:
parent
1b426ccd8b
commit
5cd053c8a9
11 changed files with 401 additions and 43 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import '../database/database.dart';
|
||||
import 'controllers/bookmarks_controller.dart';
|
||||
import 'controllers/reader_settings_controller.dart'
|
||||
show ReaderSettingsController;
|
||||
import 'controllers/subscriptions_controller.dart';
|
||||
|
|
@ -12,12 +14,18 @@ import 'pages/mews_urls.dart';
|
|||
/// miss is a bug rather than something to explain to the reader.
|
||||
class InternalActions {
|
||||
InternalActions({
|
||||
required MewsDatabase db,
|
||||
required ReaderSettingsController settings,
|
||||
required BookmarksController bookmarks,
|
||||
required SubscriptionsController subscriptions,
|
||||
}) : _settings = settings,
|
||||
}) : _db = db,
|
||||
_settings = settings,
|
||||
_bookmarks = bookmarks,
|
||||
_subscriptions = subscriptions;
|
||||
|
||||
final MewsDatabase _db;
|
||||
final ReaderSettingsController _settings;
|
||||
final BookmarksController _bookmarks;
|
||||
final SubscriptionsController _subscriptions;
|
||||
|
||||
Future<bool> apply(String url) async {
|
||||
|
|
@ -33,6 +41,10 @@ class InternalActions {
|
|||
'mark-unread' => _markRead(args, read: false),
|
||||
'refresh-subscriptions' => _refreshAll(),
|
||||
'refresh-subscription' => _refreshOne(args['url']),
|
||||
'remove-bookmark' => _withUrl(args, _bookmarks.remove),
|
||||
'unsubscribe' => _withUrl(args, _subscriptions.remove),
|
||||
'forget-page' => _withUrl(args, _db.forgetPage),
|
||||
'clear-history' => _clearHistory(),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
|
@ -43,6 +55,20 @@ class InternalActions {
|
|||
_ => Future.value(false),
|
||||
};
|
||||
|
||||
/// Runs [change] on the address the action names, if it names one.
|
||||
Future<bool> _withUrl(
|
||||
Map<String, String> args, Future<void> Function(String) change) async {
|
||||
final url = args['url'];
|
||||
if (url == null || url.isEmpty) return false;
|
||||
await change(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> _clearHistory() async {
|
||||
await _db.clearHistory();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> _markRead(Map<String, String> args, {required bool read}) async {
|
||||
final url = args['url'];
|
||||
if (url == null || url.isEmpty) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue