Ordered server list

This commit is contained in:
2026-08-28 23:16:41 +02:00
parent ff8160dc48
commit c4409683e5
4 changed files with 30 additions and 17 deletions
+18 -7
View File
@@ -37,7 +37,7 @@ export default class Enclave<P = Page> {
public config?: Config;
public constructor() {
this.serverList = {};
this.serverList = [];
this.forceRender = () => {};
this.isSettingsOpen = false;
}
@@ -113,13 +113,17 @@ export default class Enclave<P = Page> {
return;
}
const serveridx = this.serverList.findIndex((server) => {
server.hostname === hostname;
});
if (
this.serverList[hostname] &&
this.serverList[hostname].publicKey !==
this.serverList[serveridx] &&
this.serverList[serveridx].publicKey !==
base58.encode(this.server.serverPublicKey)
) {
console.error("Server's new public key doesn't match old one", {
old: this.serverList[hostname].publicKey,
old: this.serverList[serveridx].publicKey,
new: base58.encode(this.server.serverPublicKey),
});
return;
@@ -156,12 +160,19 @@ export default class Enclave<P = Page> {
this.server.meta = metaResponse.data as any;
this.serverList[hostname] = {
meta: metaResponse.data as any,
isSecure,
const serverItem = {
hostname,
publicKey: base58.encode(this.server.serverPublicKey),
isSecure,
meta: metaResponse.data as any,
};
if (this.serverList[serveridx]) {
this.serverList[serveridx] = serverItem;
} else {
this.serverList.push(serverItem);
}
this.forceRender();
}