Browse Source

neon_news,neon_notes: Remove some usages of AccountsBloc

pull/436/head
jld3103 1 year ago
parent
commit
6bea8f47f4
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 10
      packages/neon/neon_news/lib/blocs/article.dart
  2. 2
      packages/neon/neon_news/lib/widgets/articles_view.dart
  3. 11
      packages/neon/neon_notes/lib/blocs/note.dart
  4. 2
      packages/neon/neon_notes/lib/widgets/notes_view.dart

10
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);
});
}

2
packages/neon/neon_news/lib/widgets/articles_view.dart

@ -194,7 +194,6 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
MaterialPageRoute(
builder: (final context) => NewsArticlePage(
bloc: NewsArticleBloc(
Provider.of<AccountsBloc>(context, listen: false).activeAccount.value!.client,
widget.bloc,
article,
),
@ -212,7 +211,6 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
MaterialPageRoute(
builder: (final context) => NewsArticlePage(
bloc: NewsArticleBloc(
Provider.of<AccountsBloc>(context, listen: false).activeAccount.value!.client,
widget.bloc,
article,
),

11
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"',

2
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<AccountsBloc>(context, listen: false).activeAccount.value!.client,
bloc,
note,
),

Loading…
Cancel
Save