Use welshman kinds
This commit is contained in:
parent
7a7af58f5c
commit
e1a7b051bd
19 changed files with 53 additions and 104 deletions
20
package.json
20
package.json
|
|
@ -70,16 +70,16 @@
|
||||||
"@types/throttle-debounce": "^5.0.2",
|
"@types/throttle-debounce": "^5.0.2",
|
||||||
"@vite-pwa/assets-generator": "^0.2.6",
|
"@vite-pwa/assets-generator": "^0.2.6",
|
||||||
"@vite-pwa/sveltekit": "^0.6.8",
|
"@vite-pwa/sveltekit": "^0.6.8",
|
||||||
"@welshman/app": "^0.8.12",
|
"@welshman/app": "^0.8.13",
|
||||||
"@welshman/content": "^0.8.12",
|
"@welshman/content": "^0.8.13",
|
||||||
"@welshman/editor": "^0.8.12",
|
"@welshman/editor": "^0.8.13",
|
||||||
"@welshman/feeds": "^0.8.12",
|
"@welshman/feeds": "^0.8.13",
|
||||||
"@welshman/lib": "^0.8.12",
|
"@welshman/lib": "^0.8.13",
|
||||||
"@welshman/net": "^0.8.12",
|
"@welshman/net": "^0.8.13",
|
||||||
"@welshman/router": "^0.8.12",
|
"@welshman/router": "^0.8.13",
|
||||||
"@welshman/signer": "^0.8.12",
|
"@welshman/signer": "^0.8.13",
|
||||||
"@welshman/store": "^0.8.12",
|
"@welshman/store": "^0.8.13",
|
||||||
"@welshman/util": "^0.8.12",
|
"@welshman/util": "^0.8.13",
|
||||||
"compressorjs-next": "^1.1.2",
|
"compressorjs-next": "^1.1.2",
|
||||||
"daisyui": "^5.5.19",
|
"daisyui": "^5.5.19",
|
||||||
"date-picker-svelte": "^2.17.0",
|
"date-picker-svelte": "^2.17.0",
|
||||||
|
|
|
||||||
BIN
pnpm-lock.yaml
BIN
pnpm-lock.yaml
Binary file not shown.
|
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {ComponentProps} from "svelte"
|
import type {ComponentProps} from "svelte"
|
||||||
import {EVENT_TIME, ZAP_GOAL, THREAD, CLASSIFIED} from "@welshman/util"
|
import {EVENT_TIME, ZAP_GOAL, THREAD, CLASSIFIED, POLL} from "@welshman/util"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
import NoteContentEventTime from "@app/components/NoteContentEventTime.svelte"
|
import NoteContentEventTime from "@app/components/NoteContentEventTime.svelte"
|
||||||
import NoteContentThread from "@app/components/NoteContentThread.svelte"
|
import NoteContentThread from "@app/components/NoteContentThread.svelte"
|
||||||
import NoteContentClassified from "@app/components/NoteContentClassified.svelte"
|
import NoteContentClassified from "@app/components/NoteContentClassified.svelte"
|
||||||
|
|
@ -21,7 +20,7 @@
|
||||||
<NoteContentClassified {...props} />
|
<NoteContentClassified {...props} />
|
||||||
{:else if props.event.kind === ZAP_GOAL}
|
{:else if props.event.kind === ZAP_GOAL}
|
||||||
<NoteContentGoal {...props} />
|
<NoteContentGoal {...props} />
|
||||||
{:else if props.event.kind === Poll}
|
{:else if props.event.kind === POLL}
|
||||||
<NoteContentPoll {...props} />
|
<NoteContentPoll {...props} />
|
||||||
{:else}
|
{:else}
|
||||||
<Content {...props} />
|
<Content {...props} />
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {ComponentProps} from "svelte"
|
import type {ComponentProps} from "svelte"
|
||||||
import {EVENT_TIME, ZAP_GOAL, THREAD, CLASSIFIED} from "@welshman/util"
|
import {EVENT_TIME, ZAP_GOAL, THREAD, CLASSIFIED, POLL} from "@welshman/util"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
import NoteContentMinimalEventTime from "@app/components/NoteContentMinimalEventTime.svelte"
|
import NoteContentMinimalEventTime from "@app/components/NoteContentMinimalEventTime.svelte"
|
||||||
import NoteContentMinimalThread from "@app/components/NoteContentMinimalThread.svelte"
|
import NoteContentMinimalThread from "@app/components/NoteContentMinimalThread.svelte"
|
||||||
import NoteContentMinimalClassified from "@app/components/NoteContentMinimalClassified.svelte"
|
import NoteContentMinimalClassified from "@app/components/NoteContentMinimalClassified.svelte"
|
||||||
|
|
@ -21,7 +20,7 @@
|
||||||
<NoteContentMinimalClassified {...props} />
|
<NoteContentMinimalClassified {...props} />
|
||||||
{:else if props.event.kind === ZAP_GOAL}
|
{:else if props.event.kind === ZAP_GOAL}
|
||||||
<NoteContentMinimalGoal {...props} />
|
<NoteContentMinimalGoal {...props} />
|
||||||
{:else if props.event.kind === Poll}
|
{:else if props.event.kind === POLL}
|
||||||
<NoteContentMinimalPoll {...props} />
|
<NoteContentMinimalPoll {...props} />
|
||||||
{:else}
|
{:else}
|
||||||
<ContentMinimal {...props} />
|
<ContentMinimal {...props} />
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {ComponentProps} from "svelte"
|
import type {ComponentProps} from "svelte"
|
||||||
import {derived} from "svelte/store"
|
import {derived} from "svelte/store"
|
||||||
import {PollResponse} from "nostr-tools/kinds"
|
import {POLL_RESPONSE} from "@welshman/util"
|
||||||
import ContentMinimal from "@app/components/ContentMinimal.svelte"
|
import ContentMinimal from "@app/components/ContentMinimal.svelte"
|
||||||
import {deriveEvents} from "@app/core/state"
|
import {deriveEvents} from "@app/core/state"
|
||||||
import {getPollResults} from "@app/util/polls"
|
import {getPollResults} from "@app/util/polls"
|
||||||
|
|
||||||
const props: ComponentProps<typeof ContentMinimal> = $props()
|
const props: ComponentProps<typeof ContentMinimal> = $props()
|
||||||
|
|
||||||
const responses = deriveEvents([{kinds: [PollResponse], "#e": [props.event.id]}])
|
const responses = deriveEvents([{kinds: [POLL_RESPONSE], "#e": [props.event.id]}])
|
||||||
|
|
||||||
const results = derived(responses, $responses => getPollResults(props.event, $responses))
|
const results = derived(responses, $responses => getPollResults(props.event, $responses))
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import type {ComponentProps} from "svelte"
|
import type {ComponentProps} from "svelte"
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {request} from "@welshman/net"
|
import {request} from "@welshman/net"
|
||||||
import {PollResponse} from "nostr-tools/kinds"
|
import {POLL_RESPONSE} from "@welshman/util"
|
||||||
import PollVotes from "@app/components/PollVotes.svelte"
|
import PollVotes from "@app/components/PollVotes.svelte"
|
||||||
import Content from "@app/components/Content.svelte"
|
import Content from "@app/components/Content.svelte"
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
request({
|
request({
|
||||||
relays: [props.url],
|
relays: [props.url],
|
||||||
filters: [{kinds: [PollResponse], "#e": [props.event.id]}],
|
filters: [{kinds: [POLL_RESPONSE], "#e": [props.event.id]}],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {insertAt, now, randomId, removeAt, removeUndefined} from "@welshman/lib"
|
import {insertAt, now, randomId, removeAt, removeUndefined} from "@welshman/lib"
|
||||||
import {makeEvent} from "@welshman/util"
|
import {makeEvent, POLL} from "@welshman/util"
|
||||||
import {publishThunk, waitForThunkError} from "@welshman/app"
|
import {publishThunk, waitForThunkError} from "@welshman/app"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
import {isMobile, preventDefault} from "@lib/html"
|
import {isMobile, preventDefault} from "@lib/html"
|
||||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||||
import HamburgerMenu from "@assets/icons/hamburger-menu.svg?dataurl"
|
import HamburgerMenu from "@assets/icons/hamburger-menu.svg?dataurl"
|
||||||
|
|
@ -145,7 +144,7 @@
|
||||||
|
|
||||||
const pollThunk = publishThunk({
|
const pollThunk = publishThunk({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
event: makeEvent(Poll, {content: title.trim(), tags}),
|
event: makeEvent(POLL, {content: title.trim(), tags}),
|
||||||
})
|
})
|
||||||
|
|
||||||
const error = await waitForThunkError(pollThunk)
|
const error = await waitForThunkError(pollThunk)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onDestroy} from "svelte"
|
import {onDestroy} from "svelte"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
|
import {POLL_RESPONSE} from "@welshman/util"
|
||||||
import {pubkey, publishThunk, abortThunk} from "@welshman/app"
|
import {pubkey, publishThunk, abortThunk} from "@welshman/app"
|
||||||
import {PollResponse} from "nostr-tools/kinds"
|
|
||||||
import {formatTimestampRelative} from "@welshman/lib"
|
import {formatTimestampRelative} from "@welshman/lib"
|
||||||
import {deriveEvents} from "@app/core/state"
|
import {deriveEvents} from "@app/core/state"
|
||||||
import {pushToast} from "@app/util/toast"
|
import {pushToast} from "@app/util/toast"
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
const {url, event}: Props = $props()
|
const {url, event}: Props = $props()
|
||||||
|
|
||||||
const responses = deriveEvents([{kinds: [PollResponse], "#e": [event.id]}])
|
const responses = deriveEvents([{kinds: [POLL_RESPONSE], "#e": [event.id]}])
|
||||||
|
|
||||||
const pollType = getPollType(event)
|
const pollType = getPollType(event)
|
||||||
const options = getPollOptions(event)
|
const options = getPollOptions(event)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Profile} from "@welshman/util"
|
import type {Profile} from "@welshman/util"
|
||||||
import {getTag, makeProfile} from "@welshman/util"
|
import {makeProfile} from "@welshman/util"
|
||||||
import {pubkey, profilesByPubkey, waitForThunkError} from "@welshman/app"
|
import {pubkey, profilesByPubkey, waitForThunkError} from "@welshman/app"
|
||||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||||
import {errorMessage} from "@lib/util"
|
import {errorMessage} from "@lib/util"
|
||||||
|
|
@ -10,26 +10,18 @@
|
||||||
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
|
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
|
||||||
import {clearModals} from "@app/util/modal"
|
import {clearModals} from "@app/util/modal"
|
||||||
import {pushToast} from "@app/util/toast"
|
import {pushToast} from "@app/util/toast"
|
||||||
import {PROTECTED} from "@app/core/state"
|
|
||||||
import {updateProfile} from "@app/core/commands"
|
import {updateProfile} from "@app/core/commands"
|
||||||
|
|
||||||
const profile = $profilesByPubkey.get($pubkey!) || makeProfile()
|
const profile = $profilesByPubkey.get($pubkey!) || makeProfile()
|
||||||
const shouldBroadcast = !getTag(PROTECTED, profile.event?.tags || [])
|
const initialValues = {profile}
|
||||||
const initialValues = {profile, shouldBroadcast}
|
|
||||||
|
|
||||||
const back = () => history.back()
|
const back = () => history.back()
|
||||||
|
|
||||||
const onsubmit = async ({
|
const onsubmit = async ({profile}: {profile: Profile}) => {
|
||||||
profile,
|
|
||||||
shouldBroadcast,
|
|
||||||
}: {
|
|
||||||
profile: Profile
|
|
||||||
shouldBroadcast: boolean
|
|
||||||
}) => {
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const error = await waitForThunkError(updateProfile({profile, shouldBroadcast}))
|
const error = await waitForThunkError(updateProfile({profile}))
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
pushToast({
|
pushToast({
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
import MapPoint from "@assets/icons/map-point.svg?dataurl"
|
import MapPoint from "@assets/icons/map-point.svg?dataurl"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import Field from "@lib/components/Field.svelte"
|
import Field from "@lib/components/Field.svelte"
|
||||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import Modal from "@lib/components/Modal.svelte"
|
import Modal from "@lib/components/Modal.svelte"
|
||||||
import ModalBody from "@lib/components/ModalBody.svelte"
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
||||||
|
|
@ -17,7 +16,6 @@
|
||||||
|
|
||||||
type Values = {
|
type Values = {
|
||||||
profile: Profile
|
profile: Profile
|
||||||
shouldBroadcast: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
@ -77,7 +75,7 @@
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#snippet input()}
|
{#snippet input()}
|
||||||
<textarea
|
<textarea
|
||||||
class="textarea textarea-bordered leading-4"
|
class="textarea textarea-bordered leading-4 w-full"
|
||||||
rows="5"
|
rows="5"
|
||||||
bind:value={values.profile.about}></textarea>
|
bind:value={values.profile.about}></textarea>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
@ -104,25 +102,6 @@
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Field>
|
</Field>
|
||||||
{/if}
|
{/if}
|
||||||
{#if !isSignup}
|
|
||||||
<FieldInline>
|
|
||||||
{#snippet label()}
|
|
||||||
<p>Broadcast Profile</p>
|
|
||||||
{/snippet}
|
|
||||||
{#snippet input()}
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
class="toggle toggle-primary"
|
|
||||||
bind:checked={values.shouldBroadcast} />
|
|
||||||
{/snippet}
|
|
||||||
{#snippet info()}
|
|
||||||
<p>
|
|
||||||
If enabled, changes will be published to the broader nostr network in addition to spaces
|
|
||||||
you are a member of.
|
|
||||||
</p>
|
|
||||||
{/snippet}
|
|
||||||
</FieldInline>
|
|
||||||
{/if}
|
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
{@render footer()}
|
{@render footer()}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
const profile = getKey<Profile>("signup.profile")!
|
const profile = getKey<Profile>("signup.profile")!
|
||||||
|
|
||||||
const initialValues = {profile, shouldBroadcast: false}
|
const initialValues = {profile}
|
||||||
|
|
||||||
const back = () => history.back()
|
const back = () => history.back()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {derived} from "svelte/store"
|
import {derived} from "svelte/store"
|
||||||
import {displayRelayUrl, EVENT_TIME, ZAP_GOAL, THREAD, CLASSIFIED} from "@welshman/util"
|
import {displayRelayUrl, EVENT_TIME, ZAP_GOAL, THREAD, CLASSIFIED, POLL} from "@welshman/util"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
import {deriveRelay, deriveRelayDisplay, createSearch, pubkey} from "@welshman/app"
|
import {deriveRelay, deriveRelayDisplay, createSearch, pubkey} from "@welshman/app"
|
||||||
import {fly} from "@lib/transition"
|
import {fly} from "@lib/transition"
|
||||||
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
||||||
|
|
@ -267,7 +266,7 @@
|
||||||
<Icon icon={CalendarMinimalistic} /> Calendar
|
<Icon icon={CalendarMinimalistic} /> Calendar
|
||||||
</SecondaryNavItem>
|
</SecondaryNavItem>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $spaceKinds.has(Poll)}
|
{#if $spaceKinds.has(POLL)}
|
||||||
<SecondaryNavItem href={pollsPath}>
|
<SecondaryNavItem href={pollsPath}>
|
||||||
<Icon icon={Revote} /> Polls
|
<Icon icon={Revote} /> Polls
|
||||||
</SecondaryNavItem>
|
</SecondaryNavItem>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import {
|
||||||
import {Nip01Signer} from "@welshman/signer"
|
import {Nip01Signer} from "@welshman/signer"
|
||||||
import type {UploadTask} from "@welshman/editor"
|
import type {UploadTask} from "@welshman/editor"
|
||||||
import type {TrustedEvent, EventContent, Profile, PublishedRoomMeta} from "@welshman/util"
|
import type {TrustedEvent, EventContent, Profile, PublishedRoomMeta} from "@welshman/util"
|
||||||
import {PollResponse} from "nostr-tools/kinds"
|
|
||||||
import {
|
import {
|
||||||
DELETE,
|
DELETE,
|
||||||
REPORT,
|
REPORT,
|
||||||
|
|
@ -33,6 +32,7 @@ import {
|
||||||
ROOMS,
|
ROOMS,
|
||||||
COMMENT,
|
COMMENT,
|
||||||
APP_DATA,
|
APP_DATA,
|
||||||
|
POLL_RESPONSE,
|
||||||
isSignedEvent,
|
isSignedEvent,
|
||||||
makeEvent,
|
makeEvent,
|
||||||
normalizeRelayUrl,
|
normalizeRelayUrl,
|
||||||
|
|
@ -53,7 +53,6 @@ import {
|
||||||
isPublishedProfile,
|
isPublishedProfile,
|
||||||
editProfile,
|
editProfile,
|
||||||
createProfile,
|
createProfile,
|
||||||
uniqTags,
|
|
||||||
ManagementMethod,
|
ManagementMethod,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
import {Pool, AuthStatus, SocketStatus} from "@welshman/net"
|
import {Pool, AuthStatus, SocketStatus} from "@welshman/net"
|
||||||
|
|
@ -85,6 +84,7 @@ import {
|
||||||
SETTINGS,
|
SETTINGS,
|
||||||
PROTECTED,
|
PROTECTED,
|
||||||
INDEXER_RELAYS,
|
INDEXER_RELAYS,
|
||||||
|
DEFAULT_RELAYS,
|
||||||
DEFAULT_BLOSSOM_SERVERS,
|
DEFAULT_BLOSSOM_SERVERS,
|
||||||
userSpaceUrls,
|
userSpaceUrls,
|
||||||
userSettingsValues,
|
userSettingsValues,
|
||||||
|
|
@ -389,7 +389,7 @@ export type PollResponseParams = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makePollResponse = ({event, selectedIds}: PollResponseParams) =>
|
export const makePollResponse = ({event, selectedIds}: PollResponseParams) =>
|
||||||
makeEvent(PollResponse, {
|
makeEvent(POLL_RESPONSE, {
|
||||||
content: "",
|
content: "",
|
||||||
tags: [["e", event.id], ...selectedIds.map(selectedId => ["response", selectedId])],
|
tags: [["e", event.id], ...selectedIds.map(selectedId => ["response", selectedId])],
|
||||||
})
|
})
|
||||||
|
|
@ -724,34 +724,18 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
|
||||||
// Update Profile
|
// Update Profile
|
||||||
|
|
||||||
export const initProfile = (profile: Profile) => {
|
export const initProfile = (profile: Profile) => {
|
||||||
const template = createProfile(profile)
|
const event = makeEvent(PROFILE, createProfile(profile))
|
||||||
|
|
||||||
// Start out protected by default
|
return publishThunk({event, relays: DEFAULT_RELAYS})
|
||||||
template.tags.push(PROTECTED)
|
|
||||||
|
|
||||||
const event = makeEvent(PROFILE, template)
|
|
||||||
|
|
||||||
// Don't publish anywhere yet, wait until they join a space
|
|
||||||
return publishThunk({event, relays: []})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateProfile = ({
|
export const updateProfile = ({profile}: {profile: Profile}) => {
|
||||||
profile,
|
|
||||||
shouldBroadcast = !getTag(PROTECTED, profile.event?.tags || []),
|
|
||||||
}: {
|
|
||||||
profile: Profile
|
|
||||||
shouldBroadcast?: boolean
|
|
||||||
}) => {
|
|
||||||
const router = Router.get()
|
const router = Router.get()
|
||||||
const template = isPublishedProfile(profile) ? editProfile(profile) : createProfile(profile)
|
const template = isPublishedProfile(profile) ? editProfile(profile) : createProfile(profile)
|
||||||
const scenarios = [router.FromRelays(get(userSpaceUrls))]
|
const scenarios = [router.FromRelays(get(userSpaceUrls)), router.FromUser(), router.Index()]
|
||||||
|
|
||||||
if (shouldBroadcast) {
|
// Remove protected tag, we used to add it
|
||||||
scenarios.push(router.FromUser(), router.Index())
|
|
||||||
template.tags = template.tags.filter(nthNe(0, "-"))
|
template.tags = template.tags.filter(nthNe(0, "-"))
|
||||||
} else {
|
|
||||||
template.tags = uniqTags([...template.tags, PROTECTED])
|
|
||||||
}
|
|
||||||
|
|
||||||
const event = makeEvent(template.kind, template)
|
const event = makeEvent(template.kind, template)
|
||||||
const relays = router.merge(scenarios).getUrls()
|
const relays = router.merge(scenarios).getUrls()
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import {context as pomadeContext} from "@pomade/core"
|
||||||
import {Capacitor} from "@capacitor/core"
|
import {Capacitor} from "@capacitor/core"
|
||||||
import {derived, readable, writable} from "svelte/store"
|
import {derived, readable, writable} from "svelte/store"
|
||||||
import * as nip19 from "nostr-tools/nip19"
|
import * as nip19 from "nostr-tools/nip19"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
import {
|
import {
|
||||||
on,
|
on,
|
||||||
gt,
|
gt,
|
||||||
|
|
@ -93,6 +92,7 @@ import {
|
||||||
THREAD,
|
THREAD,
|
||||||
CLASSIFIED,
|
CLASSIFIED,
|
||||||
WRAP,
|
WRAP,
|
||||||
|
POLL,
|
||||||
PROFILE,
|
PROFILE,
|
||||||
ZAP_GOAL,
|
ZAP_GOAL,
|
||||||
ZAP_REQUEST,
|
ZAP_REQUEST,
|
||||||
|
|
@ -327,7 +327,7 @@ if (ENABLE_ZAPS) {
|
||||||
REACTION_KINDS.push(ZAP_RESPONSE)
|
REACTION_KINDS.push(ZAP_RESPONSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CONTENT_KINDS = [ZAP_GOAL, EVENT_TIME, THREAD, CLASSIFIED, Poll]
|
export const CONTENT_KINDS = [ZAP_GOAL, EVENT_TIME, THREAD, CLASSIFIED, POLL]
|
||||||
|
|
||||||
export const DM_KINDS = [DIRECT_MESSAGE, DIRECT_MESSAGE_FILE]
|
export const DM_KINDS = [DIRECT_MESSAGE, DIRECT_MESSAGE_FILE]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import type {Unsubscriber} from "svelte/store"
|
import type {Unsubscriber} from "svelte/store"
|
||||||
import {last, call, assoc, chunk, WEEK, ago} from "@welshman/lib"
|
import {last, call, assoc, chunk, WEEK, ago} from "@welshman/lib"
|
||||||
import {PollResponse} from "nostr-tools/kinds"
|
|
||||||
import {merged} from "@welshman/store"
|
import {merged} from "@welshman/store"
|
||||||
import {
|
import {
|
||||||
getListTags,
|
getListTags,
|
||||||
|
|
@ -20,6 +19,7 @@ import {
|
||||||
RELAY_ADD_MEMBER,
|
RELAY_ADD_MEMBER,
|
||||||
RELAY_REMOVE_MEMBER,
|
RELAY_REMOVE_MEMBER,
|
||||||
MESSAGE,
|
MESSAGE,
|
||||||
|
POLL_RESPONSE,
|
||||||
isSignedEvent,
|
isSignedEvent,
|
||||||
unionFilters,
|
unionFilters,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
|
|
@ -280,7 +280,7 @@ const syncSpace = (url: string) => {
|
||||||
filters: [
|
filters: [
|
||||||
{kinds: [...relayKinds, ...roomMetaKinds, ...roomDeleteKinds, ...CONTENT_KINDS, MESSAGE]},
|
{kinds: [...relayKinds, ...roomMetaKinds, ...roomDeleteKinds, ...CONTENT_KINDS, MESSAGE]},
|
||||||
makeCommentFilter(CONTENT_KINDS, {since}),
|
makeCommentFilter(CONTENT_KINDS, {since}),
|
||||||
{kinds: [...REACTION_KINDS, PollResponse], since},
|
{kinds: [...REACTION_KINDS, POLL_RESPONSE], since},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import {page} from "$app/stores"
|
||||||
import {nthEq} from "@welshman/lib"
|
import {nthEq} from "@welshman/lib"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {getAddress} from "@welshman/util"
|
import {getAddress} from "@welshman/util"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
import {tracker, userMessagingRelayList} from "@welshman/app"
|
import {tracker, userMessagingRelayList} from "@welshman/app"
|
||||||
import {identity} from "@welshman/lib"
|
import {identity} from "@welshman/lib"
|
||||||
import {
|
import {
|
||||||
|
|
@ -16,6 +15,7 @@ import {
|
||||||
CLASSIFIED,
|
CLASSIFIED,
|
||||||
ZAP_GOAL,
|
ZAP_GOAL,
|
||||||
EVENT_TIME,
|
EVENT_TIME,
|
||||||
|
POLL,
|
||||||
getPubkeyTagValues,
|
getPubkeyTagValues,
|
||||||
getRelaysFromList,
|
getRelaysFromList,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
|
|
@ -149,7 +149,7 @@ export const getEventPath = (event: TrustedEvent, urls: string[]) => {
|
||||||
return makeCalendarPath(url, getAddress(event))
|
return makeCalendarPath(url, getAddress(event))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.kind === Poll) {
|
if (event.kind === POLL) {
|
||||||
return makePollPath(url, event.id)
|
return makePollPath(url, event.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ export const getRoomItemPath = (url: string, event: TrustedEvent) => {
|
||||||
return makeGoalPath(url, event.id)
|
return makeGoalPath(url, event.id)
|
||||||
case EVENT_TIME:
|
case EVENT_TIME:
|
||||||
return makeCalendarPath(url, getAddress(event))
|
return makeCalendarPath(url, getAddress(event))
|
||||||
case Poll:
|
case POLL:
|
||||||
return makePollPath(url, event.id)
|
return makePollPath(url, event.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {sortBy, partition, spec, pushToMapKey, max} from "@welshman/lib"
|
import {sortBy, partition, spec, pushToMapKey, max} from "@welshman/lib"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {getTagValue} from "@welshman/util"
|
import {getTagValue, POLL} from "@welshman/util"
|
||||||
import {fly} from "@lib/transition"
|
import {fly} from "@lib/transition"
|
||||||
import PollIcon from "@assets/icons/revote.svg?dataurl"
|
import PollIcon from "@assets/icons/revote.svg?dataurl"
|
||||||
import Add from "@assets/icons/add.svg?dataurl"
|
import Add from "@assets/icons/add.svg?dataurl"
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
import SpaceBar from "@app/components/SpaceBar.svelte"
|
import SpaceBar from "@app/components/SpaceBar.svelte"
|
||||||
import PollItem from "@app/components/PollItem.svelte"
|
import PollItem from "@app/components/PollItem.svelte"
|
||||||
import PollCreate from "@app/components/PollCreate.svelte"
|
import PollCreate from "@app/components/PollCreate.svelte"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
import {decodeRelay, makeCommentFilter} from "@app/core/state"
|
import {decodeRelay, makeCommentFilter} from "@app/core/state"
|
||||||
import {makeFeed} from "@app/core/requests"
|
import {makeFeed} from "@app/core/requests"
|
||||||
import {pushModal} from "@app/util/modal"
|
import {pushModal} from "@app/util/modal"
|
||||||
|
|
@ -31,7 +30,7 @@
|
||||||
|
|
||||||
const items = $derived.by(() => {
|
const items = $derived.by(() => {
|
||||||
const scores = new Map<string, number[]>()
|
const scores = new Map<string, number[]>()
|
||||||
const [polls, comments] = partition(spec({kind: Poll}), $events)
|
const [polls, comments] = partition(spec({kind: POLL}), $events)
|
||||||
|
|
||||||
for (const comment of comments) {
|
for (const comment of comments) {
|
||||||
const id = getTagValue("E", comment.tags)
|
const id = getTagValue("E", comment.tags)
|
||||||
|
|
@ -48,7 +47,7 @@
|
||||||
const feed = makeFeed({
|
const feed = makeFeed({
|
||||||
url,
|
url,
|
||||||
element: element!,
|
element: element!,
|
||||||
filters: [{kinds: [Poll]}, makeCommentFilter([Poll])],
|
filters: [{kinds: [POLL]}, makeCommentFilter([POLL])],
|
||||||
onBackwardExhausted: () => {
|
onBackwardExhausted: () => {
|
||||||
loading = false
|
loading = false
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {sleep} from "@welshman/lib"
|
import {sleep} from "@welshman/lib"
|
||||||
import type {MakeNonOptional} from "@welshman/lib"
|
import type {MakeNonOptional} from "@welshman/lib"
|
||||||
import {COMMENT} from "@welshman/util"
|
import {COMMENT, POLL, POLL_RESPONSE} from "@welshman/util"
|
||||||
import {repository} from "@welshman/app"
|
import {repository} from "@welshman/app"
|
||||||
import {request} from "@welshman/net"
|
import {request} from "@welshman/net"
|
||||||
import {deriveEventsById, deriveEventsAsc} from "@welshman/store"
|
import {deriveEventsById, deriveEventsAsc} from "@welshman/store"
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
import CommentActions from "@app/components/CommentActions.svelte"
|
import CommentActions from "@app/components/CommentActions.svelte"
|
||||||
import EventReply from "@app/components/EventReply.svelte"
|
import EventReply from "@app/components/EventReply.svelte"
|
||||||
import {deriveEvent, decodeRelay} from "@app/core/state"
|
import {deriveEvent, decodeRelay} from "@app/core/state"
|
||||||
import {Poll, PollResponse} from "nostr-tools/kinds"
|
|
||||||
|
|
||||||
const {relay, id} = $page.params as MakeNonOptional<typeof $page.params>
|
const {relay, id} = $page.params as MakeNonOptional<typeof $page.params>
|
||||||
const url = decodeRelay(relay)
|
const url = decodeRelay(relay)
|
||||||
|
|
@ -48,7 +47,7 @@
|
||||||
|
|
||||||
request({
|
request({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
filters: [{kinds: [Poll], ids: [id]}, {kinds: [PollResponse], "#e": [id]}, ...filters],
|
filters: [{kinds: [POLL], ids: [id]}, {kinds: [POLL_RESPONSE], "#e": [id]}, ...filters],
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
ZAP_GOAL,
|
ZAP_GOAL,
|
||||||
EVENT_TIME,
|
EVENT_TIME,
|
||||||
COMMENT,
|
COMMENT,
|
||||||
|
POLL,
|
||||||
getTagValue,
|
getTagValue,
|
||||||
getTagValues,
|
getTagValues,
|
||||||
getIdAndAddress,
|
getIdAndAddress,
|
||||||
|
|
@ -50,7 +51,6 @@
|
||||||
import RecentConversation from "@app/components/RecentConversation.svelte"
|
import RecentConversation from "@app/components/RecentConversation.svelte"
|
||||||
import {decodeRelay, deriveEventsForUrl, CONTENT_KINDS} from "@app/core/state"
|
import {decodeRelay, deriveEventsForUrl, CONTENT_KINDS} from "@app/core/state"
|
||||||
import {goToEvent} from "@app/util/routes"
|
import {goToEvent} from "@app/util/routes"
|
||||||
import {Poll} from "nostr-tools/kinds"
|
|
||||||
|
|
||||||
const url = decodeRelay($page.params.relay!)
|
const url = decodeRelay($page.params.relay!)
|
||||||
const since = ago(3, MONTH)
|
const since = ago(3, MONTH)
|
||||||
|
|
@ -305,7 +305,7 @@
|
||||||
<GoalItem {url} {event} />
|
<GoalItem {url} {event} />
|
||||||
{:else if event.kind === EVENT_TIME}
|
{:else if event.kind === EVENT_TIME}
|
||||||
<CalendarEventItem {url} {event} />
|
<CalendarEventItem {url} {event} />
|
||||||
{:else if event.kind === Poll}
|
{:else if event.kind === POLL}
|
||||||
<PollItem {url} {event} />
|
<PollItem {url} {event} />
|
||||||
{:else}
|
{:else}
|
||||||
<NoteItem {url} {event} />
|
<NoteItem {url} {event} />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue