This commit is contained in:
Scott E. Graves 2025-03-24 13:02:59 -05:00
parent 2496679165
commit 7607fe68e2
2 changed files with 30 additions and 30 deletions

View File

@ -101,6 +101,35 @@ class Mount with ChangeNotifier {
} }
} }
Future<void> clearMountLocation() async {
try {
mountConfig.path = "";
final auth = await _auth.createAuth();
final response = await http.delete(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/mount_location?auth=$auth&name=$name&type=$type',
),
),
);
if (response.statusCode == 401) {
_auth.logoff();
return;
}
if (response.statusCode == 404) {
_mountList?.reset();
return;
}
return refresh();
} catch (e) {
debugPrint('$e');
}
}
Future<List<String>> getAvailableLocations() async { Future<List<String>> getAvailableLocations() async {
try { try {
final auth = await _auth.createAuth(); final auth = await _auth.createAuth();
@ -253,33 +282,4 @@ class Mount with ChangeNotifier {
debugPrint('$e'); debugPrint('$e');
} }
} }
Future<void> clearPath() async {
try {
mountConfig.path = "";
final auth = await _auth.createAuth();
final response = await http.delete(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/mount_location?auth=$auth&name=$name&type=$type',
),
),
);
if (response.statusCode == 401) {
_auth.logoff();
return;
}
if (response.statusCode == 404) {
_mountList?.reset();
return;
}
return refresh();
} catch (e) {
debugPrint('$e');
}
}
} }

View File

@ -66,7 +66,7 @@ class _MountWidgetState extends State<MountWidget> {
if (mount.mounted != null && !mount.mounted!) if (mount.mounted != null && !mount.mounted!)
IconButton( IconButton(
icon: Icon(Icons.clear), icon: Icon(Icons.clear),
onPressed: () => mount.clearPath(), onPressed: () => mount.clearMountLocation(),
), ),
IconButton( IconButton(
icon: Icon( icon: Icon(