Browse Source

Merge pull request #47 from jld3103/feature/news-option-disable-mark-as-read-timeout

neon: Add option to disable mark as read timeout in news
pull/48/head
jld3103 2 years ago committed by GitHub
parent
commit
72f841da78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/neon/lib/l10n/en.arb
  2. 6
      packages/neon/lib/l10n/localizations.dart
  3. 3
      packages/neon/lib/l10n/localizations_en.dart
  4. 9
      packages/neon/lib/src/apps/news/options.dart
  5. 14
      packages/neon/lib/src/apps/news/pages/article.dart

1
packages/neon/lib/l10n/en.arb

@ -231,6 +231,7 @@
"newsOptionsArticleViewTypeDirect": "Show text directly",
"newsOptionsArticleViewTypeInternalBrowser": "Open in internal browser",
"newsOptionsArticleViewTypeExternalBrowser": "Open in external browser",
"newsOptionsArticleDisableMarkAsReadTimeout": "Mark articles as read instantly",
"newsOptionsDefaultArticlesFilter": "Articles to show by default",
"newsOptionsArticlesSortProperty": "How to sort articles",
"newsOptionsArticlesSortPropertyPublishDate": "Publish date",

6
packages/neon/lib/l10n/localizations.dart

@ -857,6 +857,12 @@ abstract class AppLocalizations {
/// **'Open in external browser'**
String get newsOptionsArticleViewTypeExternalBrowser;
/// No description provided for @newsOptionsArticleDisableMarkAsReadTimeout.
///
/// In en, this message translates to:
/// **'Mark articles as read instantly'**
String get newsOptionsArticleDisableMarkAsReadTimeout;
/// No description provided for @newsOptionsDefaultArticlesFilter.
///
/// In en, this message translates to:

3
packages/neon/lib/l10n/localizations_en.dart

@ -419,6 +419,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get newsOptionsArticleViewTypeExternalBrowser => 'Open in external browser';
@override
String get newsOptionsArticleDisableMarkAsReadTimeout => 'Mark articles as read instantly';
@override
String get newsOptionsDefaultArticlesFilter => 'Articles to show by default';

9
packages/neon/lib/src/apps/news/options.dart

@ -11,6 +11,7 @@ class NewsAppSpecificOptions extends NextcloudAppSpecificOptions {
super.options = [
defaultCategoryOption,
articleViewTypeOption,
articleDisableMarkAsReadTimeoutOption,
defaultArticlesFilterOption,
articlesSortPropertyOption,
articlesSortBoxOrderOption,
@ -72,6 +73,14 @@ class NewsAppSpecificOptions extends NextcloudAppSpecificOptions {
values: _articleViewTypeValuesSubject,
);
late final articleDisableMarkAsReadTimeoutOption = ToggleOption(
storage: super.storage,
category: articlesCategory,
key: 'article-disable-mark-as-read-timeout',
label: (final context) => AppLocalizations.of(context).newsOptionsArticleDisableMarkAsReadTimeout,
defaultValue: BehaviorSubject.seeded(false),
);
late final defaultArticlesFilterOption = SelectOption<FilterType>(
storage: super.storage,
category: articlesCategory,

14
packages/neon/lib/src/apps/news/pages/article.dart

@ -57,11 +57,15 @@ class _NewsArticlePageState extends State<NewsArticlePage> {
void _startMarkAsReadTimer() {
if (article.unread!) {
_markAsReadTimer = Timer(const Duration(seconds: 3), () {
if (article.unread!) {
widget.bloc.markArticleAsRead(article);
}
});
if (widget.bloc.newsBloc.options.articleDisableMarkAsReadTimeoutOption.value) {
widget.bloc.markArticleAsRead(article);
} else {
_markAsReadTimer = Timer(const Duration(seconds: 3), () {
if (article.unread!) {
widget.bloc.markArticleAsRead(article);
}
});
}
}
}

Loading…
Cancel
Save