Skip to content

Commit

Permalink
always show connected node at top of nodes list
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcottle committed Nov 17, 2024
1 parent 5b48d25 commit 77a6092
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/components/nodes/NodesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@

<!-- nodes -->
<div class="h-full overflow-y-auto">

<!-- always show connected node first -->
<NodeListItem v-if="myNode" :key="myNode.num" :node="myNode" @click="onNodeClick(myNode)" class="border-b"/>

<!-- other nodes -->
<NodeListItem :key="node.num" v-for="node of searchedNodes" :node="node" @click="onNodeClick(node)"/>

</div>

</div>
Expand Down Expand Up @@ -47,20 +53,30 @@ 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);
});
},
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;
Expand Down

0 comments on commit 77a6092

Please sign in to comment.