feat: check every subscription in the background and add the posts page
This commit is contained in:
parent
953ae798eb
commit
1b426ccd8b
15 changed files with 688 additions and 58 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import 'controllers/reader_settings_controller.dart'
|
||||
show ReaderSettingsController;
|
||||
import 'controllers/subscriptions_controller.dart';
|
||||
import 'pages/mews_urls.dart';
|
||||
|
||||
/// Applies the change an action address encodes, e.g. mews:do/set-theme.
|
||||
|
|
@ -10,10 +11,14 @@ import 'pages/mews_urls.dart';
|
|||
/// only links carrying these addresses are the ones the client builds, so a
|
||||
/// miss is a bug rather than something to explain to the reader.
|
||||
class InternalActions {
|
||||
InternalActions({required ReaderSettingsController settings})
|
||||
: _settings = settings;
|
||||
InternalActions({
|
||||
required ReaderSettingsController settings,
|
||||
required SubscriptionsController subscriptions,
|
||||
}) : _settings = settings,
|
||||
_subscriptions = subscriptions;
|
||||
|
||||
final ReaderSettingsController _settings;
|
||||
final SubscriptionsController _subscriptions;
|
||||
|
||||
Future<bool> apply(String url) async {
|
||||
final verb = MewsUrls.verbOf(url);
|
||||
|
|
@ -24,6 +29,10 @@ class InternalActions {
|
|||
'set-size' => _setSize(args['step']),
|
||||
'set-theme' => _settings.setThemeMode(args['value'] ?? ''),
|
||||
'set-colors' => _settings.setVariant(args['value'] ?? ''),
|
||||
'mark-read' => _markRead(args, read: true),
|
||||
'mark-unread' => _markRead(args, read: false),
|
||||
'refresh-subscriptions' => _refreshAll(),
|
||||
'refresh-subscription' => _refreshOne(args['url']),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
|
@ -33,4 +42,28 @@ class InternalActions {
|
|||
'down' => _settings.decreaseSize(),
|
||||
_ => Future.value(false),
|
||||
};
|
||||
|
||||
Future<bool> _markRead(Map<String, String> args, {required bool read}) async {
|
||||
final url = args['url'];
|
||||
if (url == null || url.isEmpty) return false;
|
||||
final site = args['site'];
|
||||
if (read) {
|
||||
await _subscriptions.markRead(url, siteUrl: site);
|
||||
} else {
|
||||
await _subscriptions.markUnread(url, siteUrl: site);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// The check redraws the page itself as it runs, so the caller need not.
|
||||
Future<bool> _refreshAll() async {
|
||||
await _subscriptions.refreshAll();
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<bool> _refreshOne(String? siteUrl) async {
|
||||
if (siteUrl == null || siteUrl.isEmpty) return false;
|
||||
await _subscriptions.refreshOne(siteUrl);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue