From 4285109c220da5cebf99a9c69513445b53dcb04d Mon Sep 17 00:00:00 2001 From: Arenukvern Date: Fri, 1 Dec 2023 14:28:40 +0200 Subject: [PATCH] fix: mutations --- lib/idea/create_idea_screen.dart | 1 - .../lib/src/data_sources/mutations/mutations.dart | 5 +++-- packages/core/lib/src/state/user_initializer.dart | 13 +++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/idea/create_idea_screen.dart b/lib/idea/create_idea_screen.dart index bc2dea3e..2351ce96 100644 --- a/lib/idea/create_idea_screen.dart +++ b/lib/idea/create_idea_screen.dart @@ -74,7 +74,6 @@ class _CreateIdeaProjectScreenState extends State { onFieldSubmitted: (final _) => onCreate(), controller: _textController, maxLength: 90, - maxLines: null, style: context.textTheme.displaySmall?.copyWith( color: textColor, ), diff --git a/packages/core/lib/src/data_sources/mutations/mutations.dart b/packages/core/lib/src/data_sources/mutations/mutations.dart index 4981a3a4..607c7a9a 100644 --- a/packages/core/lib/src/data_sources/mutations/mutations.dart +++ b/packages/core/lib/src/data_sources/mutations/mutations.dart @@ -12,14 +12,14 @@ enum LocalDbVersion { static const newestVersion = v3_17; } -Future runMutations(final GlobalStatesInitializerDto dto) async { +Future runMutations(final GlobalStatesInitializerDto dto) async { final userNotifier = dto.userNotifier; if (userNotifier.isLoading) { throw ArgumentError.value('user is not loaded yet'); } final currentLocalDbVersion = userNotifier.value.value.localDbVersion; - if (currentLocalDbVersion == LocalDbVersion.newestVersion) return; + if (currentLocalDbVersion == LocalDbVersion.newestVersion) return false; try { await ComplexLocalDbHiveImpl().open(); for (final v in LocalDbVersion.values) { @@ -37,6 +37,7 @@ Future runMutations(final GlobalStatesInitializerDto dto) async { } userNotifier.updateLocalDbVersion(LocalDbVersion.newestVersion); + return true; } Future _mutate_3_16_up_3_17(final GlobalStatesInitializerDto dto) async { diff --git a/packages/core/lib/src/state/user_initializer.dart b/packages/core/lib/src/state/user_initializer.dart index 6582ddfb..317fdc99 100644 --- a/packages/core/lib/src/state/user_initializer.dart +++ b/packages/core/lib/src/state/user_initializer.dart @@ -4,14 +4,19 @@ class UserInitializer { UserInitializer({required this.dto}); final GlobalStatesInitializerDto dto; Future onUserLoad() async { - await runMutations(dto); - - /// not wait for this since it has its own loader - unawaited(_onDelayedLoad()); + final isAnyMigrationsExecuted = await runMutations(dto); + if (isAnyMigrationsExecuted) { + /// not wait for this since it has its own loader + unawaited(_onDelayedLoad()); + } else { + unawaited(dto.projectsNotifier.onLoad()); + } } Future _onDelayedLoad() async { + /// refreshing data, just to make sure all is loaded await Future.delayed(const Duration(seconds: 1)); + dto.projectsNotifier.onReset(); await dto.projectsNotifier.onLoad(); }