forked from coracle/flotilla
Add mobile layout
This commit is contained in:
+27
-24
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user