fix(mobile): no album thumbnail lead to no album selection shown and add global logs (#1841)

* fix(mobile): no album thumbnail lead to no album selection shown

* add more log info

* added global error handling

* better place to init logger

* get more log
This commit is contained in:
Alex
2023-02-23 00:36:17 -06:00
committed by GitHub
parent 98a8be82e2
commit a2549c5bbd
4 changed files with 112 additions and 88 deletions

View File

@@ -31,6 +31,7 @@ import 'package:immich_mobile/shared/views/version_announcement_overlay.dart';
import 'package:immich_mobile/utils/immich_app_theme.dart';
import 'package:immich_mobile/utils/migration.dart';
import 'package:isar/isar.dart';
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
import 'constants/hive_box.dart';
@@ -72,6 +73,18 @@ Future<void> initApp() async {
// Initialize Immich Logger Service
ImmichLogger().init();
var log = Logger("ImmichErrorLogger");
FlutterError.onError = (details) {
FlutterError.presentError(details);
log.severe(details.toString(), details, details.stack);
};
PlatformDispatcher.instance.onError = (error, stack) {
log.severe(error.toString(), error, stack);
return true;
};
}
Future<Isar> loadDb() async {
@@ -127,8 +140,9 @@ class ImmichAppState extends ConsumerState<ImmichApp>
ref.watch(releaseInfoProvider.notifier).checkGithubReleaseInfo();
ref.watch(notificationPermissionProvider.notifier)
.getNotificationPermission();
ref
.watch(notificationPermissionProvider.notifier)
.getNotificationPermission();
break;

View File

@@ -204,10 +204,19 @@ class BackupNotifier extends StateNotifier<BackUpState> {
if (assetList.isNotEmpty) {
var thumbnailAsset = assetList.first;
var thumbnailData = await thumbnailAsset
.thumbnailDataWithSize(const ThumbnailSize(512, 512));
availableAlbum =
availableAlbum.copyWith(thumbnailData: thumbnailData);
try {
var thumbnailData = await thumbnailAsset
.thumbnailDataWithSize(const ThumbnailSize(512, 512));
availableAlbum =
availableAlbum.copyWith(thumbnailData: thumbnailData);
} catch (e, stack) {
log.severe(
"Failed to get thumbnail for album ${album.name}",
e.toString(),
stack,
);
}
}
availableAlbums.add(availableAlbum);

View File

@@ -77,7 +77,8 @@ class AssetService {
.map((e) => Asset.local(e, userId))
.toList(growable: false);
}
} catch (e) {
} catch (e, stackTrace) {
log.severe('Error while getting local assets', e, stackTrace);
debugPrint("Error [_getLocalAssets] ${e.toString()}");
}
return null;