status messages during initialization
This commit is contained in:
@@ -20,16 +20,36 @@ class AppInitializationService extends _$AppInitializationService {
|
||||
final errors = <ErrorMessage>[];
|
||||
|
||||
//Ensure Package info is loaded
|
||||
state = Result.success(
|
||||
(
|
||||
initialized: false,
|
||||
stage: 'Loading Package Info...',
|
||||
errors: List.empty()
|
||||
),
|
||||
);
|
||||
await ref.read(packageInfoProvider.future);
|
||||
|
||||
state = Result.success(
|
||||
(
|
||||
initialized: false,
|
||||
stage: 'Synchronizing Bangs...',
|
||||
errors: List.empty()
|
||||
),
|
||||
);
|
||||
final syncResults = await ref
|
||||
.read(bangSyncRepositoryProvider.notifier)
|
||||
.syncAllBangGroups(syncInterval: const Duration(days: 7));
|
||||
|
||||
for (final MapEntry(value: result) in syncResults.entries) {
|
||||
result.onFailure(errors.add);
|
||||
}
|
||||
|
||||
state = Result.success(
|
||||
(
|
||||
initialized: false,
|
||||
stage: 'Enforcing Privacy...',
|
||||
errors: List.empty()
|
||||
),
|
||||
);
|
||||
final settings = await ref.read(settingsRepositoryProvider.future);
|
||||
if (settings.incognitoMode) {
|
||||
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
|
||||
Result<({bool initialized, List<ErrorMessage> errors})> build() {
|
||||
return Result.success((initialized: false, errors: List.empty()));
|
||||
Result<({bool initialized, String? stage, List<ErrorMessage> errors})>
|
||||
build() {
|
||||
return Result.success(
|
||||
(initialized: false, stage: null, errors: List.empty()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,18 @@ part of 'app_initialization.dart';
|
||||
// **************************************************************************
|
||||
|
||||
String _$appInitializationServiceHash() =>
|
||||
r'7b36828c2368c3b3a97b799dd8192854629c8379';
|
||||
r'9d970ee0c347a1fc89bea6546956a51ba8d2d711';
|
||||
|
||||
/// See also [AppInitializationService].
|
||||
@ProviderFor(AppInitializationService)
|
||||
final appInitializationServiceProvider = NotifierProvider<
|
||||
AppInitializationService,
|
||||
Result<({bool initialized, List<ErrorMessage> errors})>>.internal(
|
||||
Result<
|
||||
({
|
||||
bool initialized,
|
||||
String? stage,
|
||||
List<ErrorMessage> errors
|
||||
})>>.internal(
|
||||
AppInitializationService.new,
|
||||
name: r'appInitializationServiceProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
@@ -23,7 +28,7 @@ final appInitializationServiceProvider = NotifierProvider<
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$AppInitializationService
|
||||
= Notifier<Result<({bool initialized, List<ErrorMessage> errors})>>;
|
||||
typedef _$AppInitializationService = Notifier<
|
||||
Result<({bool initialized, String? stage, List<ErrorMessage> errors})>>;
|
||||
// ignore_for_file: type=lint
|
||||
// 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(
|
||||
(initializationState) {
|
||||
if (!initializationState.initialized) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
return MaterialApp(
|
||||
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