Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): sync status page goes blank when the counts query fails (#31642)

Santo Shakil398a04e11d1c
diff --git a/i18n/en.json b/i18n/en.json
index f8a01225c0..8751bc790c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1815,6 +1815,7 @@
"reset_sqlite_confirmation": "Are you sure you want to clear the app data? This will remove all settings and sign you out.",
"reset_sqlite_confirmation_note": "Note: You will need to restart the app after clearing.",
"reset_sqlite_done": "App data has been cleared. Please restart Immich and log in again.",
+ "reset_sqlite_error_hint": "Something went wrong, reset the local database with the button below",
"reset_sqlite_success": "Successfully reset the SQLite database",
"reset_to_default": "Reset to default",
"resolution": "Resolution",
diff --git a/mobile/lib/widgets/settings/beta_sync_settings/sync_status_and_actions.dart b/mobile/lib/widgets/settings/beta_sync_settings/sync_status_and_actions.dart
index 291d68f78f..da59562133 100644
--- a/mobile/lib/widgets/settings/beta_sync_settings/sync_status_and_actions.dart
+++ b/mobile/lib/widgets/settings/beta_sync_settings/sync_status_and_actions.dart
@@ -243,18 +243,14 @@ class _SyncStatsCounts extends ConsumerWidget {
}
if (snapshot.hasError) {
- return ListView(
- children: [
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Center(
- child: Text(
- "Error occur, reset the local database by tapping the button below",
- style: context.textTheme.bodyLarge,
- ),
- ),
+ return Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Center(
+ child: Text(
+ context.t.reset_sqlite_error_hint,
+ style: context.textTheme.bodyLarge?.copyWith(color: context.colorScheme.error),
),
- ],
+ ),
);
}
diff --git a/mobile/test/widgets/settings/beta_sync_settings/sync_status_and_actions_test.dart b/mobile/test/widgets/settings/beta_sync_settings/sync_status_and_actions_test.dart
new file mode 100644
index 0000000000..85a1497596
--- /dev/null
+++ b/mobile/test/widgets/settings/beta_sync_settings/sync_status_and_actions_test.dart
@@ -0,0 +1,31 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
+import 'package:immich_mobile/widgets/settings/beta_sync_settings/sync_status_and_actions.dart';
+import 'package:mocktail/mocktail.dart';
+
+import '../../../infrastructure/repository.mock.dart';
+import '../../../unit/presentation/presentation_context.dart';
+
+void main() {
+ late PresentationContext context;
+
+ setUp(() async => context = await PresentationContext.create());
+ tearDown(() => context.dispose());
+
+ testWidgets('keeps the reset button reachable when the counts fail', (tester) async {
+ final drift = MockDrift();
+ when(() => drift.localAlbumRepository).thenReturn(MockLocalAlbumRepository());
+ when(() => drift.memoryRepository).thenReturn(MockMemoryRepository());
+ when(() => context.service.asset.service.getAssetCounts()).thenThrow(Exception('corrupt db'));
+
+ await tester.pumpTestWidget(
+ context,
+ const SyncStatusAndActions(),
+ overrides: [driftProvider.overrideWithValue(drift)],
+ );
+
+ expect(tester.takeException(), isNull);
+ expect(find.text('Something went wrong, reset the local database with the button below'), findsOneWidget);
+ expect(find.text('Reset SQLite Database'), findsOneWidget);
+ });
+}