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
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user