status messages during initialization
This commit is contained in:
@@ -20,16 +20,36 @@ class AppInitializationService extends _$AppInitializationService {
|
|||||||
final errors = <ErrorMessage>[];
|
final errors = <ErrorMessage>[];
|
||||||
|
|
||||||
//Ensure Package info is loaded
|
//Ensure Package info is loaded
|
||||||
|
state = Result.success(
|
||||||
|
(
|
||||||
|
initialized: false,
|
||||||
|
stage: 'Loading Package Info...',
|
||||||
|
errors: List.empty()
|
||||||
|
),
|
||||||
|
);
|
||||||
await ref.read(packageInfoProvider.future);
|
await ref.read(packageInfoProvider.future);
|
||||||
|
|
||||||
|
state = Result.success(
|
||||||
|
(
|
||||||
|
initialized: false,
|
||||||
|
stage: 'Synchronizing Bangs...',
|
||||||
|
errors: List.empty()
|
||||||
|
),
|
||||||
|
);
|
||||||
final syncResults = await ref
|
final syncResults = await ref
|
||||||
.read(bangSyncRepositoryProvider.notifier)
|
.read(bangSyncRepositoryProvider.notifier)
|
||||||
.syncAllBangGroups(syncInterval: const Duration(days: 7));
|
.syncAllBangGroups(syncInterval: const Duration(days: 7));
|
||||||
|
|
||||||
for (final MapEntry(value: result) in syncResults.entries) {
|
for (final MapEntry(value: result) in syncResults.entries) {
|
||||||
result.onFailure(errors.add);
|
result.onFailure(errors.add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state = Result.success(
|
||||||
|
(
|
||||||
|
initialized: false,
|
||||||
|
stage: 'Enforcing Privacy...',
|
||||||
|
errors: List.empty()
|
||||||
|
),
|
||||||
|
);
|
||||||
final settings = await ref.read(settingsRepositoryProvider.future);
|
final settings = await ref.read(settingsRepositoryProvider.future);
|
||||||
if (settings.incognitoMode) {
|
if (settings.incognitoMode) {
|
||||||
await ref.read(sessionServiceProvider.notifier).clearAllData();
|
await ref.read(sessionServiceProvider.notifier).clearAllData();
|
||||||
@@ -43,12 +63,15 @@ class AppInitializationService extends _$AppInitializationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (initialized: true, errors: errors);
|
return (initialized: true, stage: null, errors: errors);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Result<({bool initialized, List<ErrorMessage> errors})> build() {
|
Result<({bool initialized, String? stage, List<ErrorMessage> errors})>
|
||||||
return Result.success((initialized: false, errors: List.empty()));
|
build() {
|
||||||
|
return Result.success(
|
||||||
|
(initialized: false, stage: null, errors: List.empty()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,18 @@ part of 'app_initialization.dart';
|
|||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$appInitializationServiceHash() =>
|
String _$appInitializationServiceHash() =>
|
||||||
r'7b36828c2368c3b3a97b799dd8192854629c8379';
|
r'9d970ee0c347a1fc89bea6546956a51ba8d2d711';
|
||||||
|
|
||||||
/// See also [AppInitializationService].
|
/// See also [AppInitializationService].
|
||||||
@ProviderFor(AppInitializationService)
|
@ProviderFor(AppInitializationService)
|
||||||
final appInitializationServiceProvider = NotifierProvider<
|
final appInitializationServiceProvider = NotifierProvider<
|
||||||
AppInitializationService,
|
AppInitializationService,
|
||||||
Result<({bool initialized, List<ErrorMessage> errors})>>.internal(
|
Result<
|
||||||
|
({
|
||||||
|
bool initialized,
|
||||||
|
String? stage,
|
||||||
|
List<ErrorMessage> errors
|
||||||
|
})>>.internal(
|
||||||
AppInitializationService.new,
|
AppInitializationService.new,
|
||||||
name: r'appInitializationServiceProvider',
|
name: r'appInitializationServiceProvider',
|
||||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||||
@@ -23,7 +28,7 @@ final appInitializationServiceProvider = NotifierProvider<
|
|||||||
allTransitiveDependencies: null,
|
allTransitiveDependencies: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef _$AppInitializationService
|
typedef _$AppInitializationService = Notifier<
|
||||||
= Notifier<Result<({bool initialized, List<ErrorMessage> errors})>>;
|
Result<({bool initialized, String? stage, List<ErrorMessage> errors})>>;
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||||
|
|||||||
+18
-2
@@ -73,8 +73,24 @@ class MainApp extends HookConsumerWidget {
|
|||||||
return initializationResult.fold(
|
return initializationResult.fold(
|
||||||
(initializationState) {
|
(initializationState) {
|
||||||
if (!initializationState.initialized) {
|
if (!initializationState.initialized) {
|
||||||
return const Center(
|
return MaterialApp(
|
||||||
child: CircularProgressIndicator(),
|
debugShowCheckedModeBanner: false,
|
||||||
|
theme: themeData,
|
||||||
|
home: Scaffold(
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const CircularProgressIndicator(),
|
||||||
|
if (initializationState.stage != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
|
child: Text(initializationState.stage!),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user