Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #1

Merged
merged 15 commits into from
Nov 29, 2023
Merged
Prev Previous commit
Next Next commit
chore: restoring backups manually no longer needs all_file_access per…
…mission

only needed for automatic
  • Loading branch information
MSOB7YY committed Nov 28, 2023
commit 32170610a542b03ff43b2441c97b0433f2ccee10
8 changes: 6 additions & 2 deletions lib/controller/backup_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ class BackupController {
});

// seems like the files are already sorted but anyways
filessss.sortByReverse((e) => e.lastModifiedSync());
backupzip = filessss.firstOrNull;

Future<void> restoreBackupOnTap(bool auto) async {
File? backupzip;
if (auto) {
final sortedFiles = await _getBackupFilesSorted.thready(_backupDirectoryPath);
backupzip = sortedFiles.firstOrNull;
} else {
final filePicked = await FilePicker.platform.pickFiles(allowedExtensions: ['zip'], type: FileType.custom);
final path = filePicked?.files.first.path;
Expand Down
12 changes: 10 additions & 2 deletions lib/ui/widgets/settings/backup_restore_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,22 @@ class BackupAndRestore extends SettingSubpageProvider {
subtitle: lang.AUTOMATIC_BACKUP_SUBTITLE,
icon: Broken.autobrightness,
maxSubtitleLines: 22,
onTap: () => BackupController.inst.restoreBackupOnTap(true),
onTap: () async {
if (!await requestManageStoragePermission()) return;

NamidaNavigator.inst.closeDialog();
BackupController.inst.restoreBackupOnTap(true);
},
),
CustomListTile(
title: lang.MANUAL_BACKUP,
subtitle: lang.MANUAL_BACKUP_SUBTITLE,
maxSubtitleLines: 22,
icon: Broken.hashtag,
onTap: () => BackupController.inst.restoreBackupOnTap(false),
onTap: () {
NamidaNavigator.inst.closeDialog();
BackupController.inst.restoreBackupOnTap(false);
},
),
],
),
Expand Down