Skip to content

Commit

Permalink
feat: fetching remote subject with Fitbit credentials on onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimozkn committed Feb 25, 2025
1 parent ae4e1a0 commit f64d9e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/lib/screens/app_onboarding/loading_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ class _LoadingScreenState extends State<LoadingScreen> {
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(*)',
],
);
Expand Down
17 changes: 17 additions & 0 deletions app/lib/screens/study/onboarding/kickoff.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class _KickoffScreen extends State<KickoffScreen> {
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<AppState>().activeSubject = subject;
context.read<AppState>().init(context);
Expand All @@ -42,6 +43,22 @@ class _KickoffScreen extends State<KickoffScreen> {
}
}

Future<StudySubject?> _fetchRemoteSubject(String selectedStudyObjectId) {
StudyULogger.debug('Fetching subject with ID: $selectedStudyObjectId');
return SupabaseQuery.getById<StudySubject>(
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();
Expand Down

0 comments on commit f64d9e5

Please sign in to comment.