CW-471-Changing-nodes-bug (#1062)

* chore: Cleanup

* fix: Node selection not updating

* fix: Node selection not updating

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
Adegoke David 2023-09-01 15:05:45 +01:00 committed by GitHub
parent e634562cf4
commit 710fe82d7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 27 deletions

View file

@ -42,36 +42,40 @@ class ManageNodesPage extends BasePage {
return nodeListViewModel.nodes.length; return nodeListViewModel.nodes.length;
}, },
itemBuilder: (_, index) { itemBuilder: (_, index) {
final node = nodeListViewModel.nodes[index]; return Observer(
final isSelected = node.keyIndex == nodeListViewModel.currentNode.keyIndex; builder: (context) {
final nodeListRow = NodeListRow( final node = nodeListViewModel.nodes[index];
title: node.uriRaw, final isSelected = node.keyIndex == nodeListViewModel.currentNode.keyIndex;
node: node, final nodeListRow = NodeListRow(
isSelected: isSelected, title: node.uriRaw,
onTap: (_) async { node: node,
if (isSelected) { isSelected: isSelected,
return; onTap: (_) async {
} if (isSelected) {
return;
}
await showPopUp<void>( await showPopUp<void>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertWithTwoActions( return AlertWithTwoActions(
alertTitle: S.of(context).change_current_node_title, alertTitle: S.of(context).change_current_node_title,
alertContent: nodeListViewModel.getAlertContent(node.uriRaw), alertContent: nodeListViewModel.getAlertContent(node.uriRaw),
leftButtonText: S.of(context).cancel, leftButtonText: S.of(context).cancel,
rightButtonText: S.of(context).change, rightButtonText: S.of(context).change,
actionLeftButton: () => Navigator.of(context).pop(), actionLeftButton: () => Navigator.of(context).pop(),
actionRightButton: () async { actionRightButton: () async {
await nodeListViewModel.setAsCurrent(node); await nodeListViewModel.setAsCurrent(node);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
); );
}); },
);
},
);
return nodeListRow;
}, },
); );
return nodeListRow;
}, },
), ),
); );

View file

@ -76,6 +76,7 @@ abstract class NodeListViewModelBase with Store {
@action @action
Future<void> delete(Node node) async => node.delete(); Future<void> delete(Node node) async => node.delete();
@action
Future<void> setAsCurrent(Node node) async => settingsStore.nodes[_appStore.wallet!.type] = node; Future<void> setAsCurrent(Node node) async => settingsStore.nodes[_appStore.wallet!.type] = node;
@action @action