fix bug fallback peer sort setting

This commit is contained in:
NicKoehler 2023-03-08 21:04:03 +01:00
parent f042ed44bd
commit c307013325
No known key found for this signature in database
GPG Key ID: BAE01394EB51AC58

View File

@ -435,7 +435,17 @@ class PeerSortDropdown extends StatefulWidget {
}
class _PeerSortDropdownState extends State<PeerSortDropdown> {
String _sortType = peerSort.value;
@override
void initState() {
if (!PeerSortType.values.contains(peerSort.value)) {
peerSort.value = PeerSortType.remoteId;
bind.setLocalFlutterConfig(
k: "peer-sorting",
v: peerSort.value,
);
}
super.initState();
}
@override
Widget build(BuildContext context) {
@ -448,17 +458,13 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
decoration: deco,
child: DropdownButtonHideUnderline(
child: DropdownButton2<String>(
value: PeerSortType.values.contains(_sortType)
? _sortType
: PeerSortType.remoteId,
onChanged: (v) async {
if (v != null) {
setState(() => _sortType = v);
setState(() => peerSort.value = v);
await bind.setLocalFlutterConfig(
k: "peer-sorting",
v: _sortType,
v: peerSort.value,
);
peerSort.value = _sortType;
}
},
customButton: Icon(
@ -488,7 +494,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
child: Row(
children: [
Icon(
value == _sortType
value == peerSort.value
? Icons.radio_button_checked_rounded
: Icons.radio_button_off_rounded,
size: 18,