Skip to content

Commit

Permalink
fix: use latest user for dashboard study table
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesvedder committed Jul 11, 2024
1 parent 61b80c4 commit 60a2876
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions designer_v2/lib/features/dashboard/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ class DashboardScreen extends ConsumerStatefulWidget {
}

class _DashboardScreenState extends ConsumerState<DashboardScreen> {
late Future<StudyUUser> user;

@override
void initState() {
super.initState();
final controller = ref.read(dashboardControllerProvider.notifier);
runAsync(() => controller.setStudiesFilter(widget.filter));
user = runAsync(() => ref.watch(userRepositoryProvider).fetchUser());
}

@override
Expand Down Expand Up @@ -86,7 +83,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
),
const SizedBox(height: 24.0), // spacing between body elements
FutureBuilder<StudyUUser>(
future: user,
future: ref.read(userRepositoryProvider).fetchUser(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return AsyncValueWidget<List<Study>>(
Expand Down
7 changes: 4 additions & 3 deletions designer_v2/lib/features/dashboard/dashboard_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ class DashboardState extends Equatable {
data: (studies) {
List<Study> updatedStudies =
studiesFilter.apply(studies: studies, user: currentUser).toList();
updatedStudies = filter(studiesToFilter: updatedStudies);
updatedStudies =
sort(pinnedStudies: pinnedStudies, studiesToSort: updatedStudies);
updatedStudies = sort(
pinnedStudies: pinnedStudies,
studiesToSort: filter(studiesToFilter: updatedStudies),
);
return AsyncValue.data(updatedStudies);
},
error: (error, _) => AsyncValue.error(error, StackTrace.current),
Expand Down

0 comments on commit 60a2876

Please sign in to comment.