From 9f56e01c47f6c418f0e200b9c9069d4acb62339f Mon Sep 17 00:00:00 2001 From: Kate Doeen Date: Wed, 13 Jul 2022 23:07:56 +0200 Subject: [PATCH] harbour: Improve previous data access in API calls --- packages/harbour/lib/src/apps/news/blocs/articles.dart | 2 +- packages/harbour/lib/src/apps/news/blocs/news.dart | 4 ++-- packages/harbour/lib/src/apps/notes/blocs/notes.dart | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/harbour/lib/src/apps/news/blocs/articles.dart b/packages/harbour/lib/src/apps/news/blocs/articles.dart index 1ee0919c..ab939a3e 100644 --- a/packages/harbour/lib/src/apps/news/blocs/articles.dart +++ b/packages/harbour/lib/src/apps/news/blocs/articles.dart @@ -157,7 +157,7 @@ class NewsArticlesBloc extends $NewsArticlesBloc { getRead: getRead, ))!, (final response) => response.items, - previousData: _articlesSubject.hasValue ? _articlesSubject.value.data : null, + previousData: _articlesSubject.valueOrNull?.data, ) .listen(_articlesSubject.add); } diff --git a/packages/harbour/lib/src/apps/news/blocs/news.dart b/packages/harbour/lib/src/apps/news/blocs/news.dart index 6a74945c..a6e264d7 100644 --- a/packages/harbour/lib/src/apps/news/blocs/news.dart +++ b/packages/harbour/lib/src/apps/news/blocs/news.dart @@ -187,7 +187,7 @@ class NewsBloc extends $NewsBloc { 'news-folders', () async => (await client.news.listFolders())!, (final response) => response.folders, - previousData: _foldersSubject.hasValue ? _foldersSubject.value.data : null, + previousData: _foldersSubject.valueOrNull?.data, ) .listen(_foldersSubject.add); } @@ -203,7 +203,7 @@ class NewsBloc extends $NewsBloc { _newestItemId = response.newestItemId; return response.feeds; }, - previousData: _feedsSubject.hasValue ? _feedsSubject.value.data : null, + previousData: _feedsSubject.valueOrNull?.data, ).listen(_feedsSubject.add); } diff --git a/packages/harbour/lib/src/apps/notes/blocs/notes.dart b/packages/harbour/lib/src/apps/notes/blocs/notes.dart index 81372db8..f2eb40ca 100644 --- a/packages/harbour/lib/src/apps/notes/blocs/notes.dart +++ b/packages/harbour/lib/src/apps/notes/blocs/notes.dart @@ -77,7 +77,7 @@ class NotesBloc extends $NotesBloc { 'notes-notes', () async => (await client.notes.getNotes())!, (final response) => response, - previousData: _notesSubject.hasValue ? _notesSubject.value.data : null, + previousData: _notesSubject.valueOrNull?.data, ) .listen(_notesSubject.add); }