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 { class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents, NewsArticleBlocStates {
NewsArticleBloc( NewsArticleBloc(
this._client,
this._newsArticlesBloc, this._newsArticlesBloc,
final NewsArticle article, final NewsArticle article,
) { ) {
@ -27,7 +26,6 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents,
starred.add(article.starred); starred.add(article.starred);
} }
final NextcloudClient _client;
final NewsArticlesBloc _newsArticlesBloc; final NewsArticlesBloc _newsArticlesBloc;
late final int _id; late final int _id;
@ -51,7 +49,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents,
@override @override
void markArticleAsRead() { void markArticleAsRead() {
_wrapArticleAction(() async { _wrapArticleAction(() async {
await _client.news.markArticleAsRead(itemId: _id); await _newsArticlesBloc.client.news.markArticleAsRead(itemId: _id);
unread.add(false); unread.add(false);
}); });
} }
@ -59,7 +57,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents,
@override @override
void markArticleAsUnread() { void markArticleAsUnread() {
_wrapArticleAction(() async { _wrapArticleAction(() async {
await _client.news.markArticleAsUnread(itemId: _id); await _newsArticlesBloc.client.news.markArticleAsUnread(itemId: _id);
unread.add(true); unread.add(true);
}); });
} }
@ -67,7 +65,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents,
@override @override
void starArticle() { void starArticle() {
_wrapArticleAction(() async { _wrapArticleAction(() async {
await _client.news.starArticle(itemId: _id); await _newsArticlesBloc.client.news.starArticle(itemId: _id);
starred.add(true); starred.add(true);
}); });
} }
@ -75,7 +73,7 @@ class NewsArticleBloc extends InteractiveBloc implements NewsArticleBlocEvents,
@override @override
void unstarArticle() { void unstarArticle() {
_wrapArticleAction(() async { _wrapArticleAction(() async {
await _client.news.unstarArticle(itemId: _id); await _newsArticlesBloc.client.news.unstarArticle(itemId: _id);
starred.add(false); starred.add(false);
}); });
} }

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

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

11
packages/neon/neon_notes/lib/blocs/note.dart

@ -14,8 +14,6 @@ abstract class NotesNoteBlocStates {
class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, NotesNoteBlocStates { class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, NotesNoteBlocStates {
NotesNoteBloc( NotesNoteBloc(
this.options,
this._client,
this._notesBloc, this._notesBloc,
final NotesNote note, final NotesNote note,
) { ) {
@ -45,8 +43,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note
}); });
} }
final NotesAppSpecificOptions options; late final NotesAppSpecificOptions options = _notesBloc.options;
final NextcloudClient _client;
final NotesBloc _notesBloc; final NotesBloc _notesBloc;
final _updateQueue = Queue(); final _updateQueue = Queue();
@ -70,7 +67,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note
@override @override
void updateCategory(final String category) { void updateCategory(final String category) {
_wrapAction( _wrapAction(
(final etag) async => _client.notes.updateNote( (final etag) async => _notesBloc.client.notes.updateNote(
id: id, id: id,
category: category, category: category,
ifMatch: '"$etag"', ifMatch: '"$etag"',
@ -81,7 +78,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note
@override @override
void updateContent(final String content) { void updateContent(final String content) {
_wrapAction( _wrapAction(
(final etag) async => _client.notes.updateNote( (final etag) async => _notesBloc.client.notes.updateNote(
id: id, id: id,
content: content, content: content,
ifMatch: '"$etag"', ifMatch: '"$etag"',
@ -92,7 +89,7 @@ class NotesNoteBloc extends InteractiveBloc implements NotesNoteBlocEvents, Note
@override @override
void updateTitle(final String title) { void updateTitle(final String title) {
_wrapAction( _wrapAction(
(final etag) async => _client.notes.updateNote( (final etag) async => _notesBloc.client.notes.updateNote(
id: id, id: id,
title: title, title: title,
ifMatch: '"$etag"', ifMatch: '"$etag"',

2
packages/neon/neon_notes/lib/widgets/notes_view.dart

@ -89,8 +89,6 @@ class NotesView extends StatelessWidget {
MaterialPageRoute( MaterialPageRoute(
builder: (final context) => NotesNotePage( builder: (final context) => NotesNotePage(
bloc: NotesNoteBloc( bloc: NotesNoteBloc(
bloc.options,
Provider.of<AccountsBloc>(context, listen: false).activeAccount.value!.client,
bloc, bloc,
note, note,
), ),

Loading…
Cancel
Save