mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(mobile): remove announcement overlay and show in app bar dialog (#5104)
Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
63a745c7ad
commit
4daf2478aa
13 changed files with 159 additions and 239 deletions
|
|
@ -18,6 +18,11 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
|||
minor: 0,
|
||||
patch: 0,
|
||||
),
|
||||
latestVersion: const ServerVersion(
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0,
|
||||
),
|
||||
serverFeatures: const ServerFeatures(
|
||||
map: true,
|
||||
trash: true,
|
||||
|
|
@ -32,6 +37,7 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
|||
diskUsagePercentage: 0,
|
||||
),
|
||||
isVersionMismatch: false,
|
||||
isNewReleaseAvailable: false,
|
||||
versionMismatchErrorMessage: "",
|
||||
),
|
||||
);
|
||||
|
|
@ -55,6 +61,10 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
|||
return;
|
||||
}
|
||||
|
||||
await _checkServerVersionMismatch(serverVersion);
|
||||
}
|
||||
|
||||
_checkServerVersionMismatch(ServerVersion serverVersion) async {
|
||||
state = state.copyWith(serverVersion: serverVersion);
|
||||
|
||||
var packageInfo = await PackageInfo.fromPlatform();
|
||||
|
|
@ -67,7 +77,15 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
|||
versionMismatchErrorMessage:
|
||||
"Server is out of date. Please update to the latest major version.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (appVersion["major"]! < serverVersion.major) {
|
||||
state = state.copyWith(
|
||||
isVersionMismatch: true,
|
||||
versionMismatchErrorMessage:
|
||||
"Mobile App is out of date. Please update to the latest major version.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -75,9 +93,17 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
|||
state = state.copyWith(
|
||||
isVersionMismatch: true,
|
||||
versionMismatchErrorMessage:
|
||||
"Server is out of date. Consider updating to the latest minor version.",
|
||||
"Server is out of date. Please update to the latest minor version.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (appVersion["minor"]! < serverVersion.minor) {
|
||||
state = state.copyWith(
|
||||
isVersionMismatch: true,
|
||||
versionMismatchErrorMessage:
|
||||
"Mobile App is out of date. Please update to the latest minor version.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -87,6 +113,25 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
|||
);
|
||||
}
|
||||
|
||||
handleNewRelease(
|
||||
ServerVersion serverVersion,
|
||||
ServerVersion latestVersion,
|
||||
) {
|
||||
// Update local server version
|
||||
_checkServerVersionMismatch(serverVersion);
|
||||
|
||||
final majorEqual = latestVersion.major == serverVersion.major;
|
||||
final minorEqual = majorEqual && latestVersion.minor == serverVersion.minor;
|
||||
final newVersionAvailable = latestVersion.major > serverVersion.major ||
|
||||
(majorEqual && latestVersion.minor > serverVersion.minor) ||
|
||||
(minorEqual && latestVersion.patch > serverVersion.patch);
|
||||
|
||||
state = state.copyWith(
|
||||
latestVersion: latestVersion,
|
||||
isNewReleaseAvailable: newVersionAvailable,
|
||||
);
|
||||
}
|
||||
|
||||
getServerFeatures() async {
|
||||
final serverFeatures = await _serverInfoService.getServerFeatures();
|
||||
if (serverFeatures == null) {
|
||||
|
|
@ -120,5 +165,5 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
|||
|
||||
final serverInfoProvider =
|
||||
StateNotifierProvider<ServerInfoNotifier, ServerInfo>((ref) {
|
||||
return ServerInfoNotifier(ref.watch(serverInfoServiceProvider));
|
||||
return ServerInfoNotifier(ref.read(serverInfoServiceProvider));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue