1
0
mirror of https://github.com/GitJournal/GitJournal.git synced 2025-07-08 00:45:13 +08:00

SyncButton: Show a different icon on error

This commit is contained in:
Vishesh Handa
2020-10-23 15:35:46 +02:00
parent 07d0bdb7d8
commit aa805f80c5
2 changed files with 13 additions and 0 deletions

@ -45,6 +45,7 @@ class Repository with ChangeNotifier {
String repoPath;
SyncStatus syncStatus = SyncStatus.Unknown;
String syncStatusError = "";
int numChanges = 0;
bool get hasJournalEntries {
@ -184,6 +185,7 @@ class Repository with ChangeNotifier {
} catch (e, stacktrace) {
Log.e("Failed to Sync", ex: e, stacktrace: stacktrace);
syncStatus = SyncStatus.Error;
syncStatusError = e.toString();
notifyListeners();
if (shouldLogGitException(e)) {
await logException(e, stacktrace);

@ -74,6 +74,17 @@ class _SyncButtonState extends State<SyncButton> {
);
}
if (repo.syncStatus == SyncStatus.Error) {
return GitPendingChangesBadge(
child: IconButton(
icon: const Icon(Icons.cloud_off),
onPressed: () async {
_syncRepo();
},
),
);
}
return GitPendingChangesBadge(
child: IconButton(
icon: Icon(_syncStatusIcon()),