feat: improved update messaging on app bar server info

This commit is contained in:
bwees 2025-10-14 13:27:17 -05:00
parent a23dfff6cf
commit 17888e68ae
No known key found for this signature in database
6 changed files with 83 additions and 49 deletions

View file

@ -24,7 +24,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
mapDarkStyleUrl: 'https://tiles.immich.cloud/v1/style/dark.json',
),
serverDiskInfo: ServerDiskInfo(diskAvailable: "0", diskSize: "0", diskUse: "0", diskUsagePercentage: 0),
isVersionMismatch: false,
isClientOutOfDate: false,
isServerOutOfDate: false,
isNewReleaseAvailable: false,
versionMismatchErrorMessage: "",
),
@ -43,15 +44,16 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
try {
final serverVersion = await _serverInfoService.getServerVersion();
// using isClientOutOfDate since that will show to users reguardless of if they are an admin
if (serverVersion == null) {
state = state.copyWith(isVersionMismatch: true, versionMismatchErrorMessage: "common_server_error".tr());
state = state.copyWith(isClientOutOfDate: true, versionMismatchErrorMessage: "common_server_error".tr());
return;
}
await _checkServerVersionMismatch(serverVersion);
} catch (e, stackTrace) {
_log.severe("Failed to get server version", e, stackTrace);
state = state.copyWith(isVersionMismatch: true);
state = state.copyWith(isClientOutOfDate: true);
return;
}
}
@ -63,39 +65,23 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
Map<String, int> appVersion = _getDetailVersion(packageInfo.version);
if (appVersion["major"]! > serverVersion.major) {
if (appVersion["major"]! > serverVersion.major || appVersion["minor"]! > serverVersion.minor) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_server_out_of_date_major".tr(),
isServerOutOfDate: true,
versionMismatchErrorMessage: "profile_drawer_server_out_of_date".tr(),
);
return;
}
if (appVersion["major"]! < serverVersion.major) {
if (appVersion["major"]! < serverVersion.major || appVersion["minor"]! < serverVersion.minor) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_client_out_of_date_major".tr(),
isClientOutOfDate: true,
versionMismatchErrorMessage: "profile_drawer_client_out_of_date".tr(),
);
return;
}
if (appVersion["minor"]! > serverVersion.minor) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_server_out_of_date_minor".tr(),
);
return;
}
if (appVersion["minor"]! < serverVersion.minor) {
state = state.copyWith(
isVersionMismatch: true,
versionMismatchErrorMessage: "profile_drawer_client_out_of_date_minor".tr(),
);
return;
}
state = state.copyWith(isVersionMismatch: false, versionMismatchErrorMessage: "");
state = state.copyWith(isClientOutOfDate: false, isServerOutOfDate: false, versionMismatchErrorMessage: "");
}
handleNewRelease(ServerVersion serverVersion, ServerVersion latestVersion) {