Skip to content

Commit

Permalink
bump: 3.3.2+1
Browse files Browse the repository at this point in the history
  • Loading branch information
Arenukvern committed Oct 22, 2021
1 parent 841364e commit 9be2f16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/screens/app/app_store_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@ class AppStoreInitializer extends ConsumerWidget {
.platformBrightness;
return FutureBuilder<bool>(
future: () async {
print('start');
if (settings.appInitialStateLoaded) {
return !settings.appInitialStateIsLoading;
}
print('settings to true');
settings
..appInitialStateLoaded = true
..appInitialStateIsLoading = true;
await SettingsStateScope.of(context).load();
print('settings loaded');

await Hive.openBox<IdeaProjectAnswer>(
HiveBoxesIds.ideaProjectAnswerKey,
);
print('ideaProjectAnswerKey loaded');

final ideas =
await Hive.openBox<IdeaProject>(HiveBoxesIds.ideaProjectKey);
print('ideas loaded');

final questions = await Hive.openBox<IdeaProjectQuestion>(
HiveBoxesIds.ideaProjectQuestionKey,
Expand All @@ -48,50 +53,64 @@ class AppStoreInitializer extends ConsumerWidget {
questions.values.map((final e) => MapEntry(e.id, e)),
),
);
print('questions loaded');

ref.read(ideaProjectsProvider.notifier).putAll(
Map.fromEntries(
ideas.values.map((final e) => MapEntry(e.id, e)),
),
);
print('ideaProjectsProvider loaded');

final notes =
await Hive.openBox<NoteProject>(HiveBoxesIds.noteProjectKey);
print('notes loaded');

ref.read(noteProjectsProvider.notifier).putAll(
Map.fromEntries(
notes.values.map((final e) => MapEntry(e.id, e)),
),
);
print('noteProjectsProvider loaded');

await Hive.openBox<StoryProject>(HiveBoxesIds.storyProjectKey);
print('StoryProject loaded');

/// ***************** MIGRATION START *******************
// TODO(arenukvern): remove old stores after all devices migration
print('migration started');
try {
print('darkModeKey started');
if (await Hive.boxExists(HiveBoxesIds.darkModeKey)) {
await Hive.deleteBoxFromDisk(HiveBoxesIds.darkModeKey);
}
print('darkModeKey ended');
print('answers migration started');
if (await Hive.boxExists(HiveBoxesIds.projectsKey) &&
await Hive.boxExists(HiveBoxesIds.answersKey)) {
await Hive.openBox<Answer>(HiveBoxesIds.answersKey);
final projects =
await Hive.openBox<Project>(HiveBoxesIds.projectsKey);
print('projects started');

for (final project in projects.values) {
print('project $project');
await project.saveAsIdeaProject(ref);
}
await Hive.deleteBoxFromDisk(HiveBoxesIds.answersKey);
await Hive.deleteBoxFromDisk(HiveBoxesIds.projectsKey);
}
print('projects completed and removed');
} catch (e) {
print('error: $e');
}

/// ***************** MIGRATION END *******************
settings.appInitialStateIsLoading = false;
print('loaded. preparing to reload');
WidgetsBinding.instance?.addPostFrameCallback((final _) {
print('notifying to reload');
settings.notify();
});
return true;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.3.1+1
version: 3.3.2+1

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down

0 comments on commit 9be2f16

Please sign in to comment.