diff --git a/packages/app/lib/src/features/home/application/feed_service.dart b/packages/app/lib/src/features/home/application/feed_service.dart index 07db04cd..7afe47fd 100644 --- a/packages/app/lib/src/features/home/application/feed_service.dart +++ b/packages/app/lib/src/features/home/application/feed_service.dart @@ -37,20 +37,19 @@ base class FeedService extends _$FeedService { ); } + // TODO(MattsAttack): This is just an unused example. It should be used or removed. /// Replace the current posts with newly generated posts. - Future replacePosts(List newPosts) async { + Future addPosts(List newPosts) async { // You can only change a Notifier's `state` by adding methods that assign a new value. // You can't mutate the state directly, nor can you change it outside of a method. - if (state case AsyncData(:final value)) { - state = AsyncData( - value.copyWith( - posts: [ - // Spread the new list into the generated list. - ...value.posts, - ...newPosts, - ], - ), + return await update((value) { + return value.copyWith( + posts: [ + // Spread the new list into the generated list. + ...value.posts, + ...newPosts, + ], ); - } + }); } }