mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 02:39:03 -04:00 
			
		
		
		
	Merge pull request #906 from immich-app/dev/reduce-startup-time
reduce app startup time by loading Hive boxes in parallel
This commit is contained in:
		
						commit
						cfa04fadd1
					
				| @ -28,17 +28,19 @@ import 'constants/hive_box.dart'; | |||||||
| 
 | 
 | ||||||
| void main() async { | void main() async { | ||||||
|   await Hive.initFlutter(); |   await Hive.initFlutter(); | ||||||
| 
 |  | ||||||
|   Hive.registerAdapter(HiveSavedLoginInfoAdapter()); |   Hive.registerAdapter(HiveSavedLoginInfoAdapter()); | ||||||
|   Hive.registerAdapter(HiveBackupAlbumsAdapter()); |   Hive.registerAdapter(HiveBackupAlbumsAdapter()); | ||||||
|   Hive.registerAdapter(HiveDuplicatedAssetsAdapter()); |   Hive.registerAdapter(HiveDuplicatedAssetsAdapter()); | ||||||
| 
 | 
 | ||||||
|   await Hive.openBox(userInfoBox); |   await Future.wait([ | ||||||
|   await Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox); |     Hive.openBox(userInfoBox), | ||||||
|   await Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox); |     Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox), | ||||||
|   await Hive.openBox(hiveGithubReleaseInfoBox); |     Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox), | ||||||
|   await Hive.openBox(userSettingInfoBox); |     Hive.openBox(hiveGithubReleaseInfoBox), | ||||||
|   await Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox); |     Hive.openBox(userSettingInfoBox), | ||||||
|  |     Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox), | ||||||
|  |     EasyLocalization.ensureInitialized(), | ||||||
|  |   ]); | ||||||
| 
 | 
 | ||||||
|   SystemChrome.setSystemUIOverlayStyle( |   SystemChrome.setSystemUIOverlayStyle( | ||||||
|     const SystemUiOverlayStyle( |     const SystemUiOverlayStyle( | ||||||
| @ -46,8 +48,6 @@ void main() async { | |||||||
|     ), |     ), | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
|   await EasyLocalization.ensureInitialized(); |  | ||||||
| 
 |  | ||||||
|   if (kReleaseMode && Platform.isAndroid) { |   if (kReleaseMode && Platform.isAndroid) { | ||||||
|     try { |     try { | ||||||
|       await FlutterDisplayMode.setHighRefreshRate(); |       await FlutterDisplayMode.setHighRefreshRate(); | ||||||
|  | |||||||
| @ -319,11 +319,14 @@ class BackgroundService { | |||||||
|     Hive.registerAdapter(HiveBackupAlbumsAdapter()); |     Hive.registerAdapter(HiveBackupAlbumsAdapter()); | ||||||
|     Hive.registerAdapter(HiveDuplicatedAssetsAdapter()); |     Hive.registerAdapter(HiveDuplicatedAssetsAdapter()); | ||||||
| 
 | 
 | ||||||
|     await Hive.openBox(userInfoBox); |     await Future.wait([ | ||||||
|     await Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox); |       Hive.openBox(userInfoBox), | ||||||
|     await Hive.openBox(userSettingInfoBox); |       Hive.openBox<HiveSavedLoginInfo>(hiveLoginInfoBox), | ||||||
|     await Hive.openBox(backgroundBackupInfoBox); |       Hive.openBox(userSettingInfoBox), | ||||||
|     await Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox); |       Hive.openBox(backgroundBackupInfoBox), | ||||||
|  |       Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox), | ||||||
|  |       Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox), | ||||||
|  |     ]); | ||||||
| 
 | 
 | ||||||
|     ApiService apiService = ApiService(); |     ApiService apiService = ApiService(); | ||||||
|     apiService.setEndpoint(Hive.box(userInfoBox).get(serverEndpointKey)); |     apiService.setEndpoint(Hive.box(userInfoBox).get(serverEndpointKey)); | ||||||
| @ -332,7 +335,7 @@ class BackgroundService { | |||||||
|     AppSettingsService settingsService = AppSettingsService(); |     AppSettingsService settingsService = AppSettingsService(); | ||||||
| 
 | 
 | ||||||
|     final Box<HiveBackupAlbums> box = |     final Box<HiveBackupAlbums> box = | ||||||
|         await Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox); |         Hive.box<HiveBackupAlbums>(hiveBackupInfoBox); | ||||||
|     final HiveBackupAlbums? backupAlbumInfo = box.get(backupInfoKey); |     final HiveBackupAlbums? backupAlbumInfo = box.get(backupInfoKey); | ||||||
|     if (backupAlbumInfo == null) { |     if (backupAlbumInfo == null) { | ||||||
|       return true; |       return true; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user