This commit is contained in:
fosse 2023-08-16 15:38:28 -04:00
parent ac67d50a47
commit 33cb419fcc
2 changed files with 13 additions and 1 deletions

View file

@ -160,6 +160,7 @@ Future defaultSettingsMigration(
case 22:
await addNanoNodeList(nodes: nodes);
await changeNanoCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
await changeNanoCurrentPowNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
break;
default:
@ -574,3 +575,10 @@ Future<void> changeNanoCurrentNodeToDefault(
await sharedPreferences.setInt(PreferencesKey.currentNanoNodeIdKey, nodeId);
}
Future<void> changeNanoCurrentPowNodeToDefault(
{required SharedPreferences sharedPreferences, required Box<Node> nodes}) async {
final node = getNanoDefaultPowNode(nodes: nodes);
final nodeId = node?.key as int? ?? 0;
await sharedPreferences.setInt(PreferencesKey.currentNanoPowNodeIdKey, nodeId);
}

View file

@ -45,7 +45,11 @@ class ManagePowNodesPage extends BasePage {
},
itemBuilder: (_, sectionIndex, index) {
final node = nodeListViewModel.nodes[index];
final isSelected = node.keyIndex == nodeListViewModel.currentNode.keyIndex;
// technically not correct but the node doesn't
// have any potentially unique attributes (keyIndex -> hashCode)
// and it fixes the bug where the default (pow) node is not highlighted until
// after making a selection
final isSelected = node.hashCode == nodeListViewModel.currentNode.hashCode;
final nodeListRow = NodeListRow(
title: node.uriRaw,
node: node,