Add button to force refetch backups list

pull/81/head
Inex Code 2021-12-09 03:35:15 +00:00
parent 35c1eea7f0
commit 2b8c009ef1
4 changed files with 25 additions and 3 deletions

View File

@ -110,7 +110,9 @@
"creating": "Creating a new backup: {}%",
"restoring": "Restoring from backup",
"error_pending": "Server returned error, check it below",
"restore_alert": "You are about to restore from backup created on {}. All current data will be lost. Are you sure?"
"restore_alert": "You are about to restore from backup created on {}. All current data will be lost. Are you sure?",
"refetchBackups": "Refetch backup list",
"refetchingList": "In a few minutes list will be updated"
}
},
"not_ready_card": {

View File

@ -110,7 +110,10 @@
"creating": "Создание копии: {}%",
"restoring": "Восстановление из копии",
"error_pending": "Сервер вернул ошибку: проверьте её ниже.",
"restore_alert": "Вы собираетесь восстановить из копии созданной {}. Все текущие данные будут потеряны. Вы уверены?"
"restore_alert": "Вы собираетесь восстановить из копии созданной {}. Все текущие данные будут потеряны. Вы уверены?",
"refetchBackups": "Обновить список копий",
"refetchingList": "Через несколько минут список будет обновлён"
}
},
"not_ready_card": {

View File

@ -148,6 +148,13 @@ class BackupsCubit extends AppConfigDependendCubit<BackupsState> {
Timer(state.refreshTimer, () => updateBackups(useTimer: true));
}
Future<void> forceUpdateBackups() async {
emit(state.copyWith(preventActions: true));
await api.forceBackupListReload();
getIt<NavigationService>().showSnackBar('providers.backup.refetchingList');
emit(state.copyWith(preventActions: false));
}
Future<void> createBackup() async {
emit(state.copyWith(preventActions: true));
await api.startBackup();

View File

@ -48,6 +48,9 @@ class _Header extends StatelessWidget {
case _PopupMenuItemType.reuploadKey:
context.read<BackupsCubit>().reuploadKey();
break;
case _PopupMenuItemType.refetchBackups:
context.read<BackupsCubit>().forceUpdateBackups();
break;
}
},
icon: Icon(Icons.more_vert),
@ -59,6 +62,13 @@ class _Header extends StatelessWidget {
child: Text('providers.backup.reuploadKey'.tr()),
),
),
PopupMenuItem<_PopupMenuItemType>(
value: _PopupMenuItemType.refetchBackups,
child: Container(
padding: EdgeInsets.only(left: 5),
child: Text('providers.backup.refetchBackups'.tr()),
),
),
],
),
),
@ -67,4 +77,4 @@ class _Header extends StatelessWidget {
}
}
enum _PopupMenuItemType { reuploadKey }
enum _PopupMenuItemType { reuploadKey, refetchBackups }