mirror of
https://github.com/melvincarvalho/nostrefresh.git
synced 2025-12-17 08:04:19 +01:00
add kinds
This commit is contained in:
17
index.js
17
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
|
const t = qs.t || 5
|
||||||
|
|
||||||
@@ -16,7 +16,8 @@
|
|||||||
filter.authors = [qs.pubkey]
|
filter.authors = [qs.pubkey]
|
||||||
}
|
}
|
||||||
if (qs.kind) {
|
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])
|
let subscribe = JSON.stringify(['REQ', 'tail', filter])
|
||||||
@@ -26,18 +27,18 @@
|
|||||||
}
|
}
|
||||||
console.log(subscribe)
|
console.log(subscribe)
|
||||||
socket.send(subscribe)
|
socket.send(subscribe)
|
||||||
}
|
};
|
||||||
|
|
||||||
socket.onmessage = function (event) {
|
socket.onmessage = function (event) {
|
||||||
const json = JSON.parse(event?.data)
|
const json = JSON.parse(event?.data)
|
||||||
if (json[0] === 'EOSE') {
|
if (json[0] === 'EOSE') {
|
||||||
console.log('EOSE')
|
console.log('EOSE')
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
console.log('refreshing in', t)
|
console.log('refreshing in', t)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.location.reload()
|
document.location.reload()
|
||||||
}, t * 1000)
|
}, t * 1000)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
})()
|
||||||
}
|
|
||||||
)()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user