From bdbaa166d94fc4c840f74f74b1503f7191716364 Mon Sep 17 00:00:00 2001 From: Fynn Petersen-Frey <10599762+fyfrey@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:21:05 +0100 Subject: [PATCH] fix(mobile): clear album provider on logout (#5477) --- mobile/lib/modules/backup/providers/backup.provider.dart | 2 ++ .../modules/login/providers/authentication.provider.dart | 8 ++++++++ mobile/lib/shared/services/sync.service.dart | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/mobile/lib/modules/backup/providers/backup.provider.dart b/mobile/lib/modules/backup/providers/backup.provider.dart index 3d8d6414c..8d50eab6e 100644 --- a/mobile/lib/modules/backup/providers/backup.provider.dart +++ b/mobile/lib/modules/backup/providers/backup.provider.dart @@ -375,6 +375,8 @@ class BackupNotifier extends StateNotifier { await _getBackupAlbumsInfo(); await updateServerInfo(); await _updateBackupAssetCount(); + } else { + log.warning("cannot get backup info - background backup is in progress!"); } } diff --git a/mobile/lib/modules/login/providers/authentication.provider.dart b/mobile/lib/modules/login/providers/authentication.provider.dart index 14a094963..34ac29b5f 100644 --- a/mobile/lib/modules/login/providers/authentication.provider.dart +++ b/mobile/lib/modules/login/providers/authentication.provider.dart @@ -5,6 +5,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_udid/flutter_udid.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/modules/album/providers/album.provider.dart'; +import 'package:immich_mobile/modules/album/providers/shared_album.provider.dart'; import 'package:immich_mobile/shared/models/store.dart'; import 'package:immich_mobile/modules/login/models/authentication_state.model.dart'; import 'package:immich_mobile/shared/models/user.dart'; @@ -21,6 +23,7 @@ class AuthenticationNotifier extends StateNotifier { AuthenticationNotifier( this._apiService, this._db, + this._ref, ) : super( AuthenticationState( deviceId: "", @@ -36,6 +39,8 @@ class AuthenticationNotifier extends StateNotifier { final ApiService _apiService; final Isar _db; + final StateNotifierProviderRef + _ref; final _log = Logger("AuthenticationNotifier"); Future login( @@ -111,6 +116,8 @@ class AuthenticationNotifier extends StateNotifier { Store.delete(StoreKey.currentUser), Store.delete(StoreKey.accessToken), ]); + _ref.invalidate(albumProvider); + _ref.invalidate(sharedAlbumProvider); state = state.copyWith( deviceId: "", @@ -222,5 +229,6 @@ final authenticationProvider = return AuthenticationNotifier( ref.watch(apiServiceProvider), ref.watch(dbProvider), + ref, ); }); diff --git a/mobile/lib/shared/services/sync.service.dart b/mobile/lib/shared/services/sync.service.dart index 08025ed71..d039b3409 100644 --- a/mobile/lib/shared/services/sync.service.dart +++ b/mobile/lib/shared/services/sync.service.dart @@ -401,6 +401,10 @@ class SyncService { final Album a = await Album.remote(dto); await _db.writeTxn(() => _db.albums.store(a)); + } else { + _log.warning( + "Failed to add album from server: assetCount ${dto.assetCount} != " + "asset array length ${dto.assets.length} for album ${dto.albumName}"); } }