From 398a04e11d1cc328a1576edd7d0578d483e0fb44 Mon Sep 17 00:00:00 2001 From: Santo Shakil Date: Fri, 18 Sep 2026 00:14:11 +0600 Subject: [PATCH] fix(mobile): sync status page goes blank when the counts query fails (#31642) * sync status page stays usable when the counts query fails * sync status error text through i18n --- i18n/en.json | 1 + .../sync_status_and_actions.dart | 18 +++++------ .../sync_status_and_actions_test.dart | 31 +++++++++++++++++++ 3 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 mobile/test/widgets/settings/beta_sync_settings/sync_status_and_actions_test.dart diff --git a/i18n/en.json b/i18n/en.json index f8a01225c..8751bc790 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 291d68f78..da5956213 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 000000000..85a149759 --- /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); + }); +}