From 6bea8f47f43c152b30129b464c7cf8ad90622ec4 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 2 Jul 2023 12:09:47 +0200 Subject: [PATCH] neon_news,neon_notes: Remove some usages of AccountsBloc --- packages/neon/neon_news/lib/blocs/article.dart | 10 ++++------ .../neon/neon_news/lib/widgets/articles_view.dart | 2 -- packages/neon/neon_notes/lib/blocs/note.dart | 11 ++++------- packages/neon/neon_notes/lib/widgets/notes_view.dart | 2 -- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/neon/neon_news/lib/blocs/article.dart b/packages/neon/neon_news/lib/blocs/article.dart index 98a4d5b1..fc6efef3 100644 --- a/packages/neon/neon_news/lib/blocs/article.dart +++ b/packages/neon/neon_news/lib/blocs/article.dart @@ -18,7 +18,6 @@ abstract class NewsArticleBlocStates { class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, NewsArticleBlocStates { NewsArticleBloc( - this._client, this._newsArticlesBloc, final NewsArticle article, ) { @@ -27,7 +26,6 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, starred.add(article.starred); } - final NextcloudClient _client; final NewsArticlesBloc _newsArticlesBloc; late final int _id; @@ -51,7 +49,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, @override void markArticleAsRead() { _wrapArticleAction(() async { - await _client.news.markArticleAsRead(itemId: _id); + await _newsArticlesBloc.client.news.markArticleAsRead(itemId: _id); unread.add(false); }); } @@ -59,7 +57,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, @override void markArticleAsUnread() { _wrapArticleAction(() async { - await _client.news.markArticleAsUnread(itemId: _id); + await _newsArticlesBloc.client.news.markArticleAsUnread(itemId: _id); unread.add(true); }); } @@ -67,7 +65,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, @override void starArticle() { _wrapArticleAction(() async { - await _client.news.starArticle(itemId: _id); + await _newsArticlesBloc.client.news.starArticle(itemId: _id); starred.add(true); }); } @@ -75,7 +73,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, @override void unstarArticle() { _wrapArticleAction(() async { - await _client.news.unstarArticle(itemId: _id); + await _newsArticlesBloc.client.news.unstarArticle(itemId: _id); starred.add(false); }); } diff --git a/packages/neon/neon_news/lib/widgets/articles_view.dart b/packages/neon/neon_news/lib/widgets/articles_view.dart index 00553afe..acd85c21 100644 --- a/packages/neon/neon_news/lib/widgets/articles_view.dart +++ b/packages/neon/neon_news/lib/widgets/articles_view.dart @@ -194,7 +194,6 @@ class _NewsArticlesViewState extends State { MaterialPageRoute( builder: (final context) => NewsArticlePage( bloc: NewsArticleBloc( - Provider.of(context, listen: false).activeAccount.value!.client, widget.bloc, article, ), @@ -212,7 +211,6 @@ class _NewsArticlesViewState extends State { MaterialPageRoute( builder: (final context) => NewsArticlePage( bloc: NewsArticleBloc( - Provider.of(context, listen: false).activeAccount.value!.client, widget.bloc, article, ), diff --git a/packages/neon/neon_notes/lib/blocs/note.dart b/packages/neon/neon_notes/lib/blocs/note.dart index bc3c06ea..b3a4eea3 100644 --- a/packages/neon/neon_notes/lib/blocs/note.dart +++ b/packages/neon/neon_notes/lib/blocs/note.dart @@ -14,8 +14,6 @@ abstract class NotesNoteBlocStates { class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, NotesNoteBlocStates { NotesNoteBloc( - this.options, - this._client, this._notesBloc, final NotesNote note, ) { @@ -45,8 +43,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note }); } - final NotesAppSpecificOptions options; - final NextcloudClient _client; + late final NotesAppSpecificOptions options = _notesBloc.options; final NotesBloc _notesBloc; final _updateQueue = Queue(); @@ -70,7 +67,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note @override void updateCategory(final String category) { _wrapAction( - (final etag) async => _client.notes.updateNote( + (final etag) async => _notesBloc.client.notes.updateNote( id: id, category: category, ifMatch: '"$etag"', @@ -81,7 +78,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note @override void updateContent(final String content) { _wrapAction( - (final etag) async => _client.notes.updateNote( + (final etag) async => _notesBloc.client.notes.updateNote( id: id, content: content, ifMatch: '"$etag"', @@ -92,7 +89,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note @override void updateTitle(final String title) { _wrapAction( - (final etag) async => _client.notes.updateNote( + (final etag) async => _notesBloc.client.notes.updateNote( id: id, title: title, ifMatch: '"$etag"', diff --git a/packages/neon/neon_notes/lib/widgets/notes_view.dart b/packages/neon/neon_notes/lib/widgets/notes_view.dart index 5bc2409c..8042fe5b 100644 --- a/packages/neon/neon_notes/lib/widgets/notes_view.dart +++ b/packages/neon/neon_notes/lib/widgets/notes_view.dart @@ -89,8 +89,6 @@ class NotesView extends StatelessWidget { MaterialPageRoute( builder: (final context) => NotesNotePage( bloc: NotesNoteBloc( - bloc.options, - Provider.of(context, listen: false).activeAccount.value!.client, bloc, note, ),