Compare commits
5 Commits
9fcc50fcc3
...
bced895ea1
Author | SHA1 | Date | |
---|---|---|---|
bced895ea1 | |||
901000a085 | |||
d5242c2e6c | |||
7c4cba6797 | |||
10a0e926ad |
@@ -45,14 +45,14 @@ namespace {
|
|||||||
return map_of_maps;
|
return map_of_maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &[prov, map] : map_of_maps) {
|
for (auto &[prov, map] : map_of_maps) {
|
||||||
for (const auto &[key, value] :
|
auto prov_str = repertory::provider_type_to_string(prov);
|
||||||
json[repertory::provider_type_to_string(prov)].items()) {
|
if (!json.contains(prov_str)) {
|
||||||
if (value.is_null()) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
map_of_maps[prov][key] = value;
|
for (const auto &[key, value] : json.at(prov_str).items()) {
|
||||||
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,6 +85,29 @@ class Mount with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String?> getMountLocation() async {
|
||||||
|
try {
|
||||||
|
final response = await http.get(
|
||||||
|
Uri.parse(
|
||||||
|
Uri.encodeFull(
|
||||||
|
'${getBaseUri()}/api/v1/mount_location?name=$name&type=$type',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final location = jsonDecode(response.body)['Location'] as String;
|
||||||
|
return location.trim().isEmpty ? null : location;
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('$e');
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> mount(bool unmount, {String? location}) async {
|
Future<bool> mount(bool unmount, {String? location}) async {
|
||||||
try {
|
try {
|
||||||
_isMounting = true;
|
_isMounting = true;
|
||||||
@@ -166,27 +189,4 @@ class Mount with ChangeNotifier {
|
|||||||
debugPrint('$e');
|
debugPrint('$e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> getMountLocation() async {
|
|
||||||
try {
|
|
||||||
final response = await http.get(
|
|
||||||
Uri.parse(
|
|
||||||
Uri.encodeFull(
|
|
||||||
'${getBaseUri()}/api/v1/mount_location?name=$name&type=$type',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final location = jsonDecode(response.body)['Location'] as String;
|
|
||||||
return location.trim().isEmpty ? null : location;
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint('$e');
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -84,6 +84,12 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
VoidCallback? _createMountHandler(context, Mount mount) {
|
VoidCallback? _createMountHandler(context, Mount mount) {
|
||||||
return _enabled && mount.mounted != null
|
return _enabled && mount.mounted != null
|
||||||
? () async {
|
? () async {
|
||||||
|
if (mount.mounted == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final mounted = mount.mounted!;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_enabled = false;
|
_enabled = false;
|
||||||
});
|
});
|
||||||
@@ -96,20 +102,23 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mount.mounted! && location == null) {
|
if (!mounted && location == null) {
|
||||||
displayErrorMessage(context, "Mount location is not set");
|
displayErrorMessage(context, "Mount location is not set");
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
final success = await mount.mount(mount.mounted!, location: location);
|
final success = await mount.mount(mounted, location: location);
|
||||||
if (success ||
|
if (success ||
|
||||||
mount.mounted! ||
|
mounted ||
|
||||||
constants.navigatorKey.currentContext == null ||
|
constants.navigatorKey.currentContext == null ||
|
||||||
!constants.navigatorKey.currentContext!.mounted) {
|
!constants.navigatorKey.currentContext!.mounted) {
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
displayErrorMessage(context, "Mount location is not available");
|
displayErrorMessage(
|
||||||
|
context,
|
||||||
|
"Mount location is not available: $location",
|
||||||
|
);
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
Reference in New Issue
Block a user