Skip to content

Commit

Permalink
fix: loading chats broken when refreshing Chats page
Browse files Browse the repository at this point in the history
  • Loading branch information
RealGoodProgrammer committed Mar 13, 2024
1 parent f19262a commit 0a63e7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/lib/nodes/abstract.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export abstract class Client<N extends Node> {
*/
protected getRandomNode() {
const onlineNodes = this.nodes.filter((x) => x.online && x.active && !x.outOfSync)
const node = onlineNodes[Math.floor(Math.random() * onlineNodes.length)]
return node
return onlineNodes[Math.floor(Math.random() * onlineNodes.length)]
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/nodes/abstract.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export abstract class Node<C = unknown> {
* Indicates whether node is out of sync (i.e. its block height is
* either too big or too small compared to the other nodes)
*/
outOfSync = true
outOfSync = false

/**
* Default `wsPort`. Will be updated after `GET /api/node/status`
Expand Down
6 changes: 4 additions & 2 deletions src/lib/nodes/utils/filterSyncedNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ export function filterSyncedNodes<N extends Node>(nodes: N[], type: NodeType): G
}
})

// A group with the longest same-height nodes list wins.
// If two groups have the same number of nodes, the one with the biggest height wins.
/** A group with the longest same-height nodes list wins.
* If two groups have the same number of nodes,
* the one with the biggest height wins.
* */
const winner = groups.reduce((acc, curr) => {
if (curr.height > acc.height || curr.nodes.length > acc.nodes.length) {
return curr
Expand Down

0 comments on commit 0a63e7a

Please sign in to comment.