Add mobile layout

This commit is contained in:
Jon Staab
2024-10-09 16:11:23 -07:00
parent 05b320cd98
commit 09c3668afd
33 changed files with 513 additions and 185 deletions
+27 -24
View File
@@ -60,7 +60,7 @@ import {
} from "@welshman/app"
import type {AppSyncOpts} from "@welshman/app"
import type {SubscribeRequestWithHandlers} from "@welshman/net"
import {deriveEvents, deriveEventsMapped, withGetter} from "@welshman/store"
import {throttled, deriveEvents, deriveEventsMapped, withGetter} from "@welshman/store"
export const ROOM = "~"
@@ -401,33 +401,36 @@ export type Thread = {
export const notes = deriveEvents(repository, {filters: [{kinds: [NOTE]}]})
export const threadsByUrl = derived([trackerStore, notes], ([$tracker, $notes]) => {
const threadsByUrl = new Map<string, Thread[]>()
const [parents, children] = partition(e => getAncestorTags(e.tags).replies.length === 0, $notes)
export const threadsByUrl = derived(
[throttled(300, trackerStore), throttled(300, notes)],
([$tracker, $notes]) => {
const threadsByUrl = new Map<string, Thread[]>()
const [parents, children] = partition(e => getAncestorTags(e.tags).replies.length === 0, $notes)
for (const event of parents) {
for (const url of $tracker.getRelays(event.id)) {
pushToMapKey(threadsByUrl, url, {root: event, replies: []})
}
}
for (const event of children) {
const [id] = getAncestorTagValues(event.tags).replies
for (const url of $tracker.getRelays(event.id)) {
const threads = threadsByUrl.get(url) || []
const thread = threads.find(thread => thread.root.id === id)
if (!thread) {
continue
for (const event of parents) {
for (const url of $tracker.getRelays(event.id)) {
pushToMapKey(threadsByUrl, url, {root: event, replies: []})
}
thread.replies.push(event)
}
}
return threadsByUrl
})
for (const event of children) {
const [id] = getAncestorTagValues(event.tags).replies
for (const url of $tracker.getRelays(event.id)) {
const threads = threadsByUrl.get(url) || []
const thread = threads.find(thread => thread.root.id === id)
if (!thread) {
continue
}
thread.replies.push(event)
}
}
return threadsByUrl
}
)
// Rooms