Split app/core up into domain-oriented files

This commit is contained in:
Jon Staab
2026-06-08 15:33:38 -07:00
parent ea6b63de53
commit 926b31de78
171 changed files with 2902 additions and 2628 deletions
+16 -1
View File
@@ -1,6 +1,7 @@
import {now, removeUndefined, uniq} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
import {getTagValue, getTags, getTagValues} from "@welshman/util"
import {POLL_RESPONSE, getTagValue, getTags, getTagValues, makeEvent} from "@welshman/util"
import {publishThunk} from "@welshman/app"
export type PollType = "singlechoice" | "multiplechoice"
@@ -74,3 +75,17 @@ export const getPollResults = (event: TrustedEvent, responses: TrustedEvent[]) =
voters: latestByPubkey.size,
}
}
export type PollResponseParams = {
event: TrustedEvent
selectedIds: string[]
}
export const makePollResponse = ({event, selectedIds}: PollResponseParams) =>
makeEvent(POLL_RESPONSE, {
content: "",
tags: [["e", event.id], ...selectedIds.map(selectedId => ["response", selectedId])],
})
export const publishPollResponse = ({relays, ...params}: PollResponseParams & {relays: string[]}) =>
publishThunk({event: makePollResponse(params), relays})