mount status fix
This commit is contained in:
parent
984f4e0bc9
commit
16bb4fe472
@ -9,6 +9,7 @@ import 'package:repertory/types/mount_config.dart';
|
|||||||
class Mount with ChangeNotifier {
|
class Mount with ChangeNotifier {
|
||||||
final MountConfig mountConfig;
|
final MountConfig mountConfig;
|
||||||
final MountList? _mountList;
|
final MountList? _mountList;
|
||||||
|
bool _isMounting = false;
|
||||||
Mount(this.mountConfig, this._mountList, {isAdd = false}) {
|
Mount(this.mountConfig, this._mountList, {isAdd = false}) {
|
||||||
if (isAdd) {
|
if (isAdd) {
|
||||||
return;
|
return;
|
||||||
@ -77,6 +78,8 @@ class Mount with ChangeNotifier {
|
|||||||
|
|
||||||
Future<bool> mount(bool unmount, {String? location}) async {
|
Future<bool> mount(bool unmount, {String? location}) async {
|
||||||
try {
|
try {
|
||||||
|
_isMounting = true;
|
||||||
|
|
||||||
mountConfig.mounted = null;
|
mountConfig.mounted = null;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
@ -89,11 +92,13 @@ class Mount with ChangeNotifier {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 404) {
|
if (response.statusCode == 404) {
|
||||||
|
_isMounting = false;
|
||||||
_mountList?.reset();
|
_mountList?.reset();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
await refresh();
|
await refresh(force: true);
|
||||||
|
_isMounting = false;
|
||||||
|
|
||||||
if (!unmount && response.statusCode == 500) {
|
if (!unmount && response.statusCode == 500) {
|
||||||
return false;
|
return false;
|
||||||
@ -102,10 +107,15 @@ class Mount with ChangeNotifier {
|
|||||||
debugPrint('$e');
|
debugPrint('$e');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isMounting = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refresh() async {
|
Future<void> refresh({bool force = false}) async {
|
||||||
|
if (!force && _isMounting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await _fetch();
|
await _fetch();
|
||||||
return _fetchStatus();
|
return _fetchStatus();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user