From f64d9e5d6d69f3cfcf0261b6b1dd87a4ae87b5a7 Mon Sep 17 00:00:00 2001 From: ibrahimozkan Date: Tue, 25 Feb 2025 22:18:00 +0200 Subject: [PATCH] feat: fetching remote subject with Fitbit credentials on onboarding --- .../screens/app_onboarding/loading_screen.dart | 6 +++++- app/lib/screens/study/onboarding/kickoff.dart | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/lib/screens/app_onboarding/loading_screen.dart b/app/lib/screens/app_onboarding/loading_screen.dart index 8e8fb2317..cb8558f00 100644 --- a/app/lib/screens/app_onboarding/loading_screen.dart +++ b/app/lib/screens/app_onboarding/loading_screen.dart @@ -66,7 +66,11 @@ class _LoadingScreenState extends State { selectedStudyObjectId, selectedColumns: [ '*', - 'study!study_subject_studyId_fkey(*)', + // Retrieve the related study along with its fitbit credentials + 'study!study_subject_studyId_fkey(' + '*,' + 'study_fitbit_credentials:study_fitbit_credentials_studyId_fkey(*)' + ')', 'subject_progress(*)', ], ); diff --git a/app/lib/screens/study/onboarding/kickoff.dart b/app/lib/screens/study/onboarding/kickoff.dart index d59c681a9..0d537ee59 100644 --- a/app/lib/screens/study/onboarding/kickoff.dart +++ b/app/lib/screens/study/onboarding/kickoff.dart @@ -25,6 +25,7 @@ class _KickoffScreen extends State { final now = DateTime.now(); subject!.startedAt = DateTime(now.year, now.month, now.day + 1).toUtc(); subject = await subject!.save(); + subject = await _fetchRemoteSubject(subject!.id); if (!context.mounted) return; context.read().activeSubject = subject; context.read().init(context); @@ -42,6 +43,22 @@ class _KickoffScreen extends State { } } + Future _fetchRemoteSubject(String selectedStudyObjectId) { + StudyULogger.debug('Fetching subject with ID: $selectedStudyObjectId'); + return SupabaseQuery.getById( + selectedStudyObjectId, + selectedColumns: [ + '*', + // Retrieve the related study along with its fitbit credentials + 'study!study_subject_studyId_fkey(' + '*,' + 'study_fitbit_credentials:study_fitbit_credentials_studyId_fkey(*)' + ')', + 'subject_progress(*)', + ], + ); + } + @override void initState() { super.initState();