From 3aa73d13216b8db2dd0324eda4f29609abfd4ce1 Mon Sep 17 00:00:00 2001 From: Melvin Carvalho Date: Tue, 28 May 2024 21:01:32 +0200 Subject: [PATCH] add kinds --- index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 4895eec..ab140d9 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ -; (() => { - globalThis.qs = Object.fromEntries(new URLSearchParams(document.location.search)) +(() => { + globalThis.qs = Object.fromEntries(new URLSearchParams(document.location.search).entries()) const t = qs.t || 5 @@ -16,7 +16,8 @@ filter.authors = [qs.pubkey] } if (qs.kind) { - filter.kinds = [parseInt(qs.kind)] + const kinds = Array.isArray(qs.kind) ? qs.kind : [qs.kind] + filter.kinds = kinds.map(kind => parseInt(kind)) } let subscribe = JSON.stringify(['REQ', 'tail', filter]) @@ -26,18 +27,18 @@ } console.log(subscribe) socket.send(subscribe) - } + }; + socket.onmessage = function (event) { const json = JSON.parse(event?.data) if (json[0] === 'EOSE') { console.log('EOSE') - return + return; } console.log('refreshing in', t) setTimeout(() => { document.location.reload() }, t * 1000) - } + }; } -} -)() +})()