Browse Source

neon: Add option to disable mark as read timeout in news

pull/47/head
jld3103 2 years ago
parent
commit
4d8e9bafc6
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  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. 4
      packages/neon/lib/src/apps/news/pages/article.dart

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

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

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

@ -857,6 +857,12 @@ abstract class AppLocalizations {
/// **'Open in external browser'** /// **'Open in external browser'**
String get newsOptionsArticleViewTypeExternalBrowser; 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. /// No description provided for @newsOptionsDefaultArticlesFilter.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

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

@ -419,6 +419,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get newsOptionsArticleViewTypeExternalBrowser => 'Open in external browser'; String get newsOptionsArticleViewTypeExternalBrowser => 'Open in external browser';
@override
String get newsOptionsArticleDisableMarkAsReadTimeout => 'Mark articles as read instantly';
@override @override
String get newsOptionsDefaultArticlesFilter => 'Articles to show by default'; 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 = [ super.options = [
defaultCategoryOption, defaultCategoryOption,
articleViewTypeOption, articleViewTypeOption,
articleDisableMarkAsReadTimeoutOption,
defaultArticlesFilterOption, defaultArticlesFilterOption,
articlesSortPropertyOption, articlesSortPropertyOption,
articlesSortBoxOrderOption, articlesSortBoxOrderOption,
@ -72,6 +73,14 @@ class NewsAppSpecificOptions extends NextcloudAppSpecificOptions {
values: _articleViewTypeValuesSubject, 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>( late final defaultArticlesFilterOption = SelectOption<FilterType>(
storage: super.storage, storage: super.storage,
category: articlesCategory, category: articlesCategory,

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

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

Loading…
Cancel
Save