fixes
This commit is contained in:
parent
1a7dc51c4b
commit
349bede3b3
@ -17,18 +17,20 @@ class MountList with ChangeNotifier {
|
|||||||
UnmodifiableListView<MountConfig>(_mountList);
|
UnmodifiableListView<MountConfig>(_mountList);
|
||||||
|
|
||||||
bool hasBucketName(String mountType, String bucket, {String? excludeName}) {
|
bool hasBucketName(String mountType, String bucket, {String? excludeName}) {
|
||||||
|
final list = items.where(
|
||||||
|
(item) => item.type.toLowerCase() == mountType.toLowerCase(),
|
||||||
|
);
|
||||||
|
|
||||||
return (excludeName == null
|
return (excludeName == null
|
||||||
? items
|
? list
|
||||||
: items.whereNot(
|
: list.whereNot(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.name.toLowerCase() == excludeName.toLowerCase(),
|
item.name.toLowerCase() == excludeName.toLowerCase(),
|
||||||
))
|
))
|
||||||
.firstWhereOrNull(
|
.firstWhereOrNull((MountConfig item) {
|
||||||
(item) =>
|
return item.bucket != null &&
|
||||||
item.type.toLowerCase() == mountType.toLowerCase() &&
|
item.bucket!.toLowerCase() == bucket.toLowerCase();
|
||||||
item.bucket != null &&
|
}) !=
|
||||||
item.bucket!.toLowerCase() == bucket.toLowerCase(),
|
|
||||||
) !=
|
|
||||||
null;
|
null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +91,9 @@ class MountList with ChangeNotifier {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_mountList = [];
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
return _fetch();
|
return _fetch();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('$e');
|
debugPrint('$e');
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@ -133,11 +132,8 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
Builder(
|
Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return ElevatedButton.icon(
|
return ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
final mountList = Provider.of<MountList>(
|
final mountList = Provider.of<MountList>(context);
|
||||||
context,
|
|
||||||
listen: false,
|
|
||||||
);
|
|
||||||
|
|
||||||
List<String> failed = [];
|
List<String> failed = [];
|
||||||
if (!validateSettings(_settings[_mountType]!, failed)) {
|
if (!validateSettings(_settings[_mountType]!, failed)) {
|
||||||
@ -183,12 +179,15 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mountList.add(
|
await mountList.add(
|
||||||
_mountType,
|
_mountType,
|
||||||
_mountNameController.text,
|
_mountNameController.text,
|
||||||
_settings[_mountType]!,
|
_settings[_mountType]!,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!context.mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
label: const Text('Add'),
|
label: const Text('Add'),
|
||||||
@ -207,12 +206,9 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
final changed = _mountType != mountType;
|
final changed = _mountType != mountType;
|
||||||
|
|
||||||
_mountType = mountType;
|
_mountType = mountType;
|
||||||
_mountNameController.text =
|
if (changed) {
|
||||||
(mountType == 'Sia' && changed)
|
_mountNameController.text = mountType == 'Sia' ? 'default' : '';
|
||||||
? 'default'
|
}
|
||||||
: changed
|
|
||||||
? ''
|
|
||||||
: _mountNameController.text;
|
|
||||||
|
|
||||||
_mount =
|
_mount =
|
||||||
(_mountNameController.text.isEmpty)
|
(_mountNameController.text.isEmpty)
|
||||||
|
@ -604,7 +604,7 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
listen: false,
|
listen: false,
|
||||||
).hasBucketName(
|
).hasBucketName(
|
||||||
widget.mount.type,
|
widget.mount.type,
|
||||||
subValue,
|
value,
|
||||||
excludeName: widget.mount.name,
|
excludeName: widget.mount.name,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -862,7 +862,7 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
listen: false,
|
listen: false,
|
||||||
).hasBucketName(
|
).hasBucketName(
|
||||||
widget.mount.type,
|
widget.mount.type,
|
||||||
subValue,
|
value,
|
||||||
excludeName: widget.mount.name,
|
excludeName: widget.mount.name,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user