nazrinharris / pecunia

Massively ambitious personal finance app.
1 stars 0 forks source link

Stuck in `EntryScreen` when very first time opening app. #131

Closed nazrinharris closed 10 months ago

nazrinharris commented 10 months ago

Here are the logs:

Launching lib/main.dart on iPhone 15 Pro Max in debug mode...
Xcode build done.                                           11.4s
[VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend.
Connecting to VM Service at ws://127.0.0.1:52753/2Ars7ne871s=/ws
flutter: ***** Supabase init completed Instance of 'Supabase'
flutter: ***** SupabaseDeepLinkingMixin startAuthObserver
flutter: (pecuniaSharedPreferencesProvider) : AsyncData<SharedPreferences>(value: Instance of 'SharedPreferences')...
flutter: (getLoggedInUserProvider) : AsyncData<Option<PecuniaUser>>(value: None)...
flutter: (getIsFirstOpenProvider) : AsyncData<Option<bool>>(value: Some(true))...
 WidgetsBinding.instance.addPostFrameCallback((_) async {
        final result = await ref.watch(getLoggedInUserProvider.future);

        if (result.isSome()) {
          context.goNamed('main');
        } else {
          debugPrint('No user logged in, checking if first open');
          ref.watch(getIsFirstOpenProvider).whenData((isFirstOpen) {
            isFirstOpen.fold(
              () => debugPrint('Not First Open'),
              (isFirstOpen) {
                debugPrint('First open check succesfull, isFirstOpen: $isFirstOpen');
                if (isFirstOpen) {
                  context.goNamed('onboarding');
                } else {
                  context.goNamed('start');
                }
              },
            );
          });
        }
      });

The culprit is the whenData. I'm guessing by the time whenData is called, getIsFirstOpenProvider is still loading. So the whole thing doesn't get executed. Only until debugPrint('No user logged in, checking if first open');.

nazrinharris commented 10 months ago

A restart of the app would seem to fix this. But this is not ideal.

Yeah this seems to happen at the first ever install.

nazrinharris commented 10 months ago

Should be completed with de414f2 in #118