Compare commits
No commits in common. "9fcc50fcc3b1bcb60ade91c44177b8d5e1751d1a" and "ee1638e1dda4437959fc7858dfce348fb455202f" have entirely different histories.
9fcc50fcc3
...
ee1638e1dd
@ -10,8 +10,6 @@ class Mount with ChangeNotifier {
|
|||||||
final MountConfig mountConfig;
|
final MountConfig mountConfig;
|
||||||
final MountList? _mountList;
|
final MountList? _mountList;
|
||||||
bool _isMounting = false;
|
bool _isMounting = false;
|
||||||
bool _isRefreshing = false;
|
|
||||||
|
|
||||||
Mount(this.mountConfig, this._mountList, {isAdd = false}) {
|
Mount(this.mountConfig, this._mountList, {isAdd = false}) {
|
||||||
if (isAdd) {
|
if (isAdd) {
|
||||||
return;
|
return;
|
||||||
@ -44,11 +42,8 @@ class Mount with ChangeNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isMounting) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mountConfig.updateSettings(jsonDecode(response.body));
|
mountConfig.updateSettings(jsonDecode(response.body));
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('$e');
|
debugPrint('$e');
|
||||||
@ -74,10 +69,6 @@ class Mount with ChangeNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isMounting) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mountConfig.updateStatus(jsonDecode(response.body));
|
mountConfig.updateStatus(jsonDecode(response.body));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -92,11 +83,6 @@ class Mount with ChangeNotifier {
|
|||||||
mountConfig.mounted = null;
|
mountConfig.mounted = null;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
var count = 0;
|
|
||||||
while (_isRefreshing && count++ < 10) {
|
|
||||||
await Future.delayed(Duration(seconds: 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
Uri.encodeFull(
|
Uri.encodeFull(
|
||||||
@ -126,20 +112,12 @@ class Mount with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refresh({bool force = false}) async {
|
Future<void> refresh({bool force = false}) async {
|
||||||
if (!force && (_isMounting || _isRefreshing)) {
|
if (!force && _isMounting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isRefreshing = true;
|
await _fetch();
|
||||||
|
return _fetchStatus();
|
||||||
try {
|
|
||||||
await _fetch();
|
|
||||||
await _fetchStatus();
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint('$e');
|
|
||||||
}
|
|
||||||
|
|
||||||
_isRefreshing = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setValue(String key, String value) async {
|
Future<void> setValue(String key, String value) async {
|
||||||
|
@ -102,6 +102,7 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final success = await mount.mount(mount.mounted!, location: location);
|
final success = await mount.mount(mount.mounted!, location: location);
|
||||||
|
|
||||||
if (success ||
|
if (success ||
|
||||||
mount.mounted! ||
|
mount.mounted! ||
|
||||||
constants.navigatorKey.currentContext == null ||
|
constants.navigatorKey.currentContext == null ||
|
||||||
@ -110,7 +111,7 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
displayErrorMessage(context, "Mount location is not available");
|
displayErrorMessage(context, "Mount location is not available");
|
||||||
cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user