diff --git a/packages/frontend/src/App.tsx b/packages/frontend/src/App.tsx index 483e564..fa3d933 100644 --- a/packages/frontend/src/App.tsx +++ b/packages/frontend/src/App.tsx @@ -10,7 +10,7 @@ import './App.css'; export default class App extends React.Component<{}, State> { public state: State; private readonly settings: PersistentObject; - private readonly pins: PersistentSet; + private readonly pins: PersistentSet; private readonly connection: Promise; constructor(props: {}) { @@ -34,11 +34,11 @@ export default class App extends React.Component<{}, State> { (settings) => this.setState({ settings }) ); - this.pins = new PersistentSet('pinned', (pins) => { + this.pins = new PersistentSet('pinned_names', (pins) => { const { nodes } = this.state; for (const node of nodes.values()) { - node.pinned = pins.has(node.id); + node.pinned = pins.has(node.nodeDetails[0]); } this.setState({ nodes, pins }); diff --git a/packages/frontend/src/Connection.ts b/packages/frontend/src/Connection.ts index 1ec8395..3fe4bb8 100644 --- a/packages/frontend/src/Connection.ts +++ b/packages/frontend/src/Connection.ts @@ -8,7 +8,7 @@ const TIMEOUT_BASE = (1000 * 5) as Types.Milliseconds; // 5 seconds const TIMEOUT_MAX = (1000 * 60 * 5) as Types.Milliseconds; // 5 minutes export class Connection { - public static async create(pins: PersistentSet, update: Update): Promise { + public static async create(pins: PersistentSet, update: Update): Promise { return new Connection(await Connection.socket(), update, pins); } @@ -65,9 +65,9 @@ export class Connection { private socket: WebSocket; private state: Readonly; private readonly update: Update; - private readonly pins: PersistentSet; + private readonly pins: PersistentSet; - constructor(socket: WebSocket, update: Update, pins: PersistentSet) { + constructor(socket: WebSocket, update: Update, pins: PersistentSet) { this.socket = socket; this.update = update; this.pins = pins; @@ -172,7 +172,7 @@ export class Connection { case Actions.AddedNode: { const [id, nodeDetails, nodeStats, blockDetails, location] = message.payload; - const pinned = this.pins.has(id); + const pinned = this.pins.has(nodeDetails[0]); const node = { pinned, id, nodeDetails, nodeStats, blockDetails, location }; nodes.set(id, node); diff --git a/packages/frontend/src/components/Chain/Chain.tsx b/packages/frontend/src/components/Chain/Chain.tsx index 01ffdab..a92b442 100644 --- a/packages/frontend/src/components/Chain/Chain.tsx +++ b/packages/frontend/src/components/Chain/Chain.tsx @@ -25,7 +25,7 @@ export namespace Chain { export interface Props { appState: Readonly; settings: PersistentObject; - pins: PersistentSet; + pins: PersistentSet; } export interface State { diff --git a/packages/frontend/src/components/Node/Row.tsx b/packages/frontend/src/components/Node/Row.tsx index b6191f0..7438fff 100644 --- a/packages/frontend/src/components/Node/Row.tsx +++ b/packages/frontend/src/components/Node/Row.tsx @@ -28,7 +28,7 @@ import './Row.css'; interface RowProps { node: AppState.Node; settings: AppState.Settings; - pins: PersistentSet; + pins: PersistentSet; }; interface HeaderProps { @@ -201,11 +201,12 @@ export default class Row extends React.Component { public toggle = () => { const { pins, node } = this.props; + const name = node.nodeDetails[0]; if (node.pinned) { - pins.delete(node.id) + pins.delete(name) } else { - pins.add(node.id); + pins.add(name); } } } diff --git a/packages/frontend/src/state.ts b/packages/frontend/src/state.ts index 5b0b90c..ff099ca 100644 --- a/packages/frontend/src/state.ts +++ b/packages/frontend/src/state.ts @@ -35,7 +35,7 @@ export interface State { chains: Map; nodes: Map; settings: Readonly; - pins: Readonly>; + pins: Readonly>; } export type Update = (changes: Pick | null) => Readonly;