sync bot toasts are more concise

This commit is contained in:
Schnitzel5 2025-02-14 15:51:19 +01:00
parent 400fd90c6e
commit 52eb0a903b
3 changed files with 5 additions and 6 deletions

View file

@ -72,7 +72,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
final l10n = l10nLocalizations(context)!;
Timer.periodic(Duration(seconds: autoSyncFrequency), (timer) {
try {
ref.read(syncServerProvider(syncId: 1).notifier).startSync(l10n);
ref.read(syncServerProvider(syncId: 1).notifier).startSync(l10n, true);
} catch (e) {
botToast(
"Failed to sync! Maybe the sync server is down. Restart the app to resume auto sync.");

View file

@ -226,7 +226,7 @@ class SyncScreen extends ConsumerWidget {
ref
.read(syncServerProvider(syncId: 1)
.notifier)
.startSync(l10n);
.startSync(l10n, false);
},
icon: Icon(
Icons.sync,

View file

@ -63,7 +63,7 @@ class SyncServer extends _$SyncServer {
}
}
Future<void> startSync(AppLocalizations l10n) async {
Future<void> startSync(AppLocalizations l10n, bool silent) async {
botToast(l10n.sync_checking, second: 2);
try {
final changedParts = ref
@ -92,7 +92,7 @@ class SyncServer extends _$SyncServer {
await downloadFromServer(l10n, true, false);
}
} else {
await forceCheck(l10n, true);
await forceCheck(l10n, silent);
}
final syncNotifier = ref.read(synchingProvider(syncId: syncId).notifier);
@ -100,7 +100,6 @@ class SyncServer extends _$SyncServer {
syncNotifier.clearAllChangedParts(true);
ref.invalidate(synchingProvider(syncId: syncId));
botToast(l10n.sync_download_finished, second: 2);
} catch (error) {
botToast(error.toString(), second: 5);
}
@ -129,7 +128,7 @@ class SyncServer extends _$SyncServer {
if (localHash != remoteHash) {
await downloadFromServer(l10n, silent, false);
} else if (!silent) {
botToast("Sync up to date", second: 2);
botToast(l10n.sync_up_to_date, second: 2);
}
} catch (error) {
botToast(error.toString(), second: 5);