From 77a6092979cd40f01609088cbe342edd2c71d253 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 17 Nov 2024 23:12:07 +1300 Subject: [PATCH] always show connected node at top of nodes list --- src/components/nodes/NodesList.vue | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/nodes/NodesList.vue b/src/components/nodes/NodesList.vue index d3321a2..3bf6d70 100644 --- a/src/components/nodes/NodesList.vue +++ b/src/components/nodes/NodesList.vue @@ -8,7 +8,13 @@
+ + + + + +
@@ -47,12 +53,22 @@ export default { GlobalState() { return GlobalState; }, + myNode() { + return this.nodes.find((node) => { + return node.num === GlobalState.myNodeId; + }); + }, + otherNodes() { + return this.nodes.filter((node) => { + return node.num !== GlobalState.myNodeId; + }); + }, orderedNodes() { return this.nodesOrderedByLastHeard; }, nodesOrderedByName() { // sort nodes by name asc - return this.nodes.sort((nodeA, nodeB) => { + return this.otherNodes.sort((nodeA, nodeB) => { const nodeALongName = this.getNodeLongName(nodeA.num); const nodeBLongName = this.getNodeLongName(nodeB.num); return nodeALongName.localeCompare(nodeBLongName); @@ -60,7 +76,7 @@ export default { }, nodesOrderedByLastHeard() { // sort nodes by last heard desc - return this.nodes.sort((nodeA, nodeB) => { + return this.otherNodes.sort((nodeA, nodeB) => { const nodeALastHeard = nodeA.lastHeard; const nodeBLastHeard = nodeB.lastHeard; return nodeBLastHeard - nodeALastHeard;