mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
chore(mobile): Improve reliability of asset loading and indexing (#1813)
* chore(mobile): Improve reliability of asset loading and indexing * chore: add comments * chore: remove log * fix: put back box open sequence
This commit is contained in:
parent
4be55428d2
commit
bf3f4e560d
@ -587,6 +587,7 @@ class BackupNotifier extends StateNotifier<BackUpState> {
|
|||||||
log.warning("WARNING [resumeBackup] failed to acquireLock");
|
log.warning("WARNING [resumeBackup] failed to acquireLock");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox),
|
Hive.openBox<HiveBackupAlbums>(hiveBackupInfoBox),
|
||||||
Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox),
|
Hive.openBox<HiveDuplicatedAssets>(duplicatedAssetsBox),
|
||||||
@ -597,17 +598,22 @@ class BackupNotifier extends StateNotifier<BackUpState> {
|
|||||||
Set<AvailableAlbum> selectedAlbums = state.selectedBackupAlbums;
|
Set<AvailableAlbum> selectedAlbums = state.selectedBackupAlbums;
|
||||||
Set<AvailableAlbum> excludedAlbums = state.excludedBackupAlbums;
|
Set<AvailableAlbum> excludedAlbums = state.excludedBackupAlbums;
|
||||||
if (albums != null) {
|
if (albums != null) {
|
||||||
|
if (selectedAlbums.isNotEmpty) {
|
||||||
selectedAlbums = _updateAlbumsBackupTime(
|
selectedAlbums = _updateAlbumsBackupTime(
|
||||||
selectedAlbums,
|
selectedAlbums,
|
||||||
albums.selectedAlbumIds,
|
albums.selectedAlbumIds,
|
||||||
albums.lastSelectedBackupTime,
|
albums.lastSelectedBackupTime,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (excludedAlbums.isNotEmpty) {
|
||||||
excludedAlbums = _updateAlbumsBackupTime(
|
excludedAlbums = _updateAlbumsBackupTime(
|
||||||
excludedAlbums,
|
excludedAlbums,
|
||||||
albums.excludedAlbumsIds,
|
albums.excludedAlbumsIds,
|
||||||
albums.lastExcludedBackupTime,
|
albums.lastExcludedBackupTime,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
final Box backgroundBox = Hive.box(backgroundBackupInfoBox);
|
final Box backgroundBox = Hive.box(backgroundBackupInfoBox);
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
backupProgress: previous,
|
backupProgress: previous,
|
||||||
|
@ -67,7 +67,7 @@ class HomePage extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
void reloadAllAsset() {
|
void reloadAllAsset() {
|
||||||
ref.read(assetProvider.notifier).getAllAsset();
|
ref.watch(assetProvider.notifier).getAllAsset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildBody() {
|
Widget buildBody() {
|
||||||
|
@ -11,6 +11,8 @@ class AuthGuard extends AutoRouteGuard {
|
|||||||
@override
|
@override
|
||||||
void onNavigation(NavigationResolver resolver, StackRouter router) async {
|
void onNavigation(NavigationResolver resolver, StackRouter router) async {
|
||||||
try {
|
try {
|
||||||
|
// temporary fix for race condition that the _apiService
|
||||||
|
// get called before accessToken is set
|
||||||
var userInfoHiveBox = await Hive.openBox(userInfoBox);
|
var userInfoHiveBox = await Hive.openBox(userInfoBox);
|
||||||
var accessToken = userInfoHiveBox.get(accessTokenKey);
|
var accessToken = userInfoHiveBox.get(accessTokenKey);
|
||||||
_apiService.setAccessToken(accessToken);
|
_apiService.setAccessToken(accessToken);
|
||||||
|
@ -35,6 +35,12 @@ class AssetService {
|
|||||||
/// Returns `null` if the server state did not change, else list of assets
|
/// Returns `null` if the server state did not change, else list of assets
|
||||||
Future<Pair<List<Asset>?, String?>> getRemoteAssets({String? etag}) async {
|
Future<Pair<List<Asset>?, String?>> getRemoteAssets({String? etag}) async {
|
||||||
try {
|
try {
|
||||||
|
// temporary fix for race condition that the _apiService
|
||||||
|
// get called before accessToken is set
|
||||||
|
var userInfoHiveBox = await Hive.openBox(userInfoBox);
|
||||||
|
var accessToken = userInfoHiveBox.get(accessTokenKey);
|
||||||
|
_apiService.setAccessToken(accessToken);
|
||||||
|
|
||||||
final Pair<List<AssetResponseDto>, String?>? remote =
|
final Pair<List<AssetResponseDto>, String?>? remote =
|
||||||
await _apiService.assetApi.getAllAssetsWithETag(eTag: etag);
|
await _apiService.assetApi.getAllAssetsWithETag(eTag: etag);
|
||||||
if (remote == null) {
|
if (remote == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user