fix(mobile): clear album provider on logout (#5477)
This commit is contained in:
parent
812e67d55d
commit
bdbaa166d9
3 changed files with 14 additions and 0 deletions
|
@ -375,6 +375,8 @@ class BackupNotifier extends StateNotifier<BackUpState> {
|
||||||
await _getBackupAlbumsInfo();
|
await _getBackupAlbumsInfo();
|
||||||
await updateServerInfo();
|
await updateServerInfo();
|
||||||
await _updateBackupAssetCount();
|
await _updateBackupAssetCount();
|
||||||
|
} else {
|
||||||
|
log.warning("cannot get backup info - background backup is in progress!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_udid/flutter_udid.dart';
|
import 'package:flutter_udid/flutter_udid.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.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/shared/models/store.dart';
|
||||||
import 'package:immich_mobile/modules/login/models/authentication_state.model.dart';
|
import 'package:immich_mobile/modules/login/models/authentication_state.model.dart';
|
||||||
import 'package:immich_mobile/shared/models/user.dart';
|
import 'package:immich_mobile/shared/models/user.dart';
|
||||||
|
@ -21,6 +23,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||||
AuthenticationNotifier(
|
AuthenticationNotifier(
|
||||||
this._apiService,
|
this._apiService,
|
||||||
this._db,
|
this._db,
|
||||||
|
this._ref,
|
||||||
) : super(
|
) : super(
|
||||||
AuthenticationState(
|
AuthenticationState(
|
||||||
deviceId: "",
|
deviceId: "",
|
||||||
|
@ -36,6 +39,8 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||||
|
|
||||||
final ApiService _apiService;
|
final ApiService _apiService;
|
||||||
final Isar _db;
|
final Isar _db;
|
||||||
|
final StateNotifierProviderRef<AuthenticationNotifier, AuthenticationState>
|
||||||
|
_ref;
|
||||||
final _log = Logger("AuthenticationNotifier");
|
final _log = Logger("AuthenticationNotifier");
|
||||||
|
|
||||||
Future<bool> login(
|
Future<bool> login(
|
||||||
|
@ -111,6 +116,8 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||||
Store.delete(StoreKey.currentUser),
|
Store.delete(StoreKey.currentUser),
|
||||||
Store.delete(StoreKey.accessToken),
|
Store.delete(StoreKey.accessToken),
|
||||||
]);
|
]);
|
||||||
|
_ref.invalidate(albumProvider);
|
||||||
|
_ref.invalidate(sharedAlbumProvider);
|
||||||
|
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
deviceId: "",
|
deviceId: "",
|
||||||
|
@ -222,5 +229,6 @@ final authenticationProvider =
|
||||||
return AuthenticationNotifier(
|
return AuthenticationNotifier(
|
||||||
ref.watch(apiServiceProvider),
|
ref.watch(apiServiceProvider),
|
||||||
ref.watch(dbProvider),
|
ref.watch(dbProvider),
|
||||||
|
ref,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -401,6 +401,10 @@ class SyncService {
|
||||||
|
|
||||||
final Album a = await Album.remote(dto);
|
final Album a = await Album.remote(dto);
|
||||||
await _db.writeTxn(() => _db.albums.store(a));
|
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue