Move alerts to their own page, add direct message alerts
This commit is contained in:
+17
-11
@@ -14,8 +14,10 @@ import {
|
||||
THREAD,
|
||||
ZAP_GOAL,
|
||||
EVENT_TIME,
|
||||
getPubkeyTagValues,
|
||||
} from "@welshman/util"
|
||||
import {
|
||||
ensureUnwrapped,
|
||||
makeChatId,
|
||||
entityLink,
|
||||
decodeRelay,
|
||||
@@ -74,24 +76,28 @@ export const getPrimaryNavItemIndex = ($page: Page) => {
|
||||
}
|
||||
|
||||
export const goToEvent = async (event: TrustedEvent, options: Record<string, any> = {}) => {
|
||||
if (event.kind === DIRECT_MESSAGE || event.kind === DIRECT_MESSAGE_FILE) {
|
||||
await scrollToEvent(event.id)
|
||||
}
|
||||
const unwrapped = await ensureUnwrapped(event)
|
||||
|
||||
const urls = Array.from(tracker.getRelays(event.id))
|
||||
const path = await getEventPath(event, urls)
|
||||
if (unwrapped) {
|
||||
const urls = Array.from(tracker.getRelays(unwrapped.id))
|
||||
const path = await getEventPath(unwrapped, urls)
|
||||
|
||||
if (path.includes("://")) {
|
||||
window.open(path)
|
||||
} else {
|
||||
goto(path, options)
|
||||
if (path.includes("://")) {
|
||||
window.open(path)
|
||||
} else {
|
||||
goto(path, options)
|
||||
|
||||
await sleep(300)
|
||||
await scrollToEvent(event.id)
|
||||
await sleep(300)
|
||||
await scrollToEvent(unwrapped.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const getEventPath = async (event: TrustedEvent, urls: string[]) => {
|
||||
if (event.kind === DIRECT_MESSAGE || event.kind === DIRECT_MESSAGE_FILE) {
|
||||
return makeChatPath([event.pubkey, ...getPubkeyTagValues(event.tags)])
|
||||
}
|
||||
|
||||
const room = getTagValue(ROOM, event.tags)
|
||||
|
||||
if (urls.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user