From c4a9d7b05339500d8d5c68905a61dfe265c0945c Mon Sep 17 00:00:00 2001 From: JC Gurango Date: Wed, 16 Aug 2023 23:50:44 +0800 Subject: [PATCH] Move saved page to new system --- lib/pages/profile_tab.dart | 3 ++- lib/pages/saved_page.dart | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pages/profile_tab.dart b/lib/pages/profile_tab.dart index 8084c99c..66296abb 100644 --- a/lib/pages/profile_tab.dart +++ b/lib/pages/profile_tab.dart @@ -20,7 +20,8 @@ class UserProfileTab extends HookWidget { final actions = [ IconButton( - onPressed: () => goTo(context, (context) => const SavedPage()), + onPressed: () => goTo( + context, (context) => SavedPage(accountsStore.defaultUserData!)), icon: const Icon(Icons.bookmark), ), IconButton( diff --git a/lib/pages/saved_page.dart b/lib/pages/saved_page.dart index 0111d657..d45b8f41 100644 --- a/lib/pages/saved_page.dart +++ b/lib/pages/saved_page.dart @@ -4,13 +4,16 @@ import 'package:lemmy_api_client/v3.dart'; import '../hooks/stores.dart'; import '../l10n/l10n.dart'; +import '../stores/accounts_store.dart'; import '../widgets/post/post_store.dart'; import '../widgets/sortable_infinite_list.dart'; /// Page with saved posts/comments. Fetches such saved data from the default user /// Assumes there is at least one logged in user class SavedPage extends HookWidget { - const SavedPage({super.key}); + final UserData userData; + + const SavedPage(this.userData, {super.key}); @override Widget build(BuildContext context) { @@ -50,10 +53,10 @@ class SavedPage extends HookWidget { savedOnly: true, page: page, limit: batchSize, - auth: accountStore.defaultUserData!.jwt.raw, + auth: userData.jwt.raw, ), ) - .toPostStores(accountStore.defaultUserData), + .toPostStores(userData), ), InfiniteCommentList( fetcher: (page, batchSize, sortType) => @@ -64,9 +67,10 @@ class SavedPage extends HookWidget { savedOnly: true, page: page, limit: batchSize, - auth: accountStore.defaultUserData!.jwt.raw, + auth: userData.jwt.raw, ), ), + userData: userData, ), ], ),