mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-16 16:33:38 +08:00
RepoManager: Implement deleting a repo
This is ugly as fuck. All of the settings pages need a more coherent look and feel, and need to be organized better. This finished the implementation of multiple repos. Fixes #229
This commit is contained in:
@ -88,4 +88,28 @@ class RepositoryManager with ChangeNotifier {
|
||||
Log.i("Switching to repo with id: $id");
|
||||
await buildActiveRepository();
|
||||
}
|
||||
|
||||
Future<void> deleteCurrent() async {
|
||||
if (repoIds.length == 1) {
|
||||
throw Exception("Last Repo cannot be deleted");
|
||||
}
|
||||
|
||||
Log.i("Deleting repo: $currentId");
|
||||
|
||||
var i = repoIds.indexOf(currentId);
|
||||
|
||||
var repoPath = _repo.repoPath;
|
||||
var cachePath = _repo.cacheDir;
|
||||
|
||||
await Directory(repoPath).delete(recursive: true);
|
||||
await Directory(cachePath).delete(recursive: true);
|
||||
|
||||
repoIds.removeAt(i);
|
||||
|
||||
i = i.clamp(0, repoIds.length - 1);
|
||||
currentId = repoIds[i];
|
||||
|
||||
await _save();
|
||||
await buildActiveRepository();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user