only show popular relays that you are not already connected to

This commit is contained in:
Martti Malmi 2023-03-16 16:07:58 +02:00
parent 59a5b96ba0
commit 8370002762

View File

@ -86,7 +86,7 @@ export default {
const content = JSON.parse(event.content);
for (const url in content) {
try {
const parsed = new URL(url).toString();
const parsed = new URL(url).toString().replace(/\/$/, '');
const count = relays.get(parsed) || 0;
relays.set(parsed, count + 1);
} catch (e) {
@ -98,7 +98,9 @@ export default {
}
}
});
const sorted = Array.from(relays.entries()).sort((a, b) => b[1] - a[1]);
const sorted = Array.from(relays.entries())
.filter(([url]) => !this.relays.has(url))
.sort((a, b) => b[1] - a[1]);
return sorted.map((entry) => {
return { url: entry[0], users: entry[1] };
});