Bump welshman

This commit is contained in:
Jon Staab
2025-01-17 15:01:05 -08:00
parent e15fb3ce9c
commit 86928fc12c
13 changed files with 70 additions and 80 deletions
+7 -29
View File
@@ -46,7 +46,7 @@ import {
loadFollows,
loadMutes,
tagEvent,
tagReactionTo,
tagEventForReaction,
getRelayUrls,
userRelaySelections,
userInboxRelaySelections,
@@ -55,6 +55,7 @@ import {
addSession,
clearStorage,
dropSession,
tagEventForComment,
} from "@welshman/app"
import type {Thunk} from "@welshman/app"
import {
@@ -459,7 +460,7 @@ export type ReactionParams = {
}
export const makeReaction = ({event, content}: ReactionParams) => {
const tags = [["k", String(event.kind)], ...tagReactionTo(event)]
const tags = tagEventForReaction(event)
const groupTag = getTag("h", event.tags)
if (groupTag) {
@@ -473,37 +474,14 @@ export const makeReaction = ({event, content}: ReactionParams) => {
export const publishReaction = ({relays, ...params}: ReactionParams & {relays: string[]}) =>
publishThunk({event: makeReaction(params), relays})
export type ReplyParams = {
export type CommentParams = {
event: TrustedEvent
content: string
tags?: string[][]
}
export const makeComment = ({event, content, tags = []}: ReplyParams) => {
const seenRoots = new Set<string>()
export const makeComment = ({event, content, tags = []}: CommentParams) =>
createEvent(COMMENT, {content, tags: [...tags, ...tagEventForComment(event)]})
for (const [raw, ...tag] of event.tags.filter(t => t[0].match(/^(k|e|a|i)$/i))) {
const T = raw.toUpperCase()
const t = raw.toLowerCase()
if (seenRoots.has(T)) {
tags.push([t, ...tag])
} else {
tags.push([T, ...tag])
seenRoots.add(T)
}
}
if (seenRoots.size === 0) {
tags.push(["K", String(event.kind)])
tags.push(["E", event.id])
}
tags.push(["k", String(event.kind)])
tags.push(["e", event.id])
return createEvent(COMMENT, {content, tags})
}
export const publishComment = ({relays, ...params}: ReplyParams & {relays: string[]}) =>
export const publishComment = ({relays, ...params}: CommentParams & {relays: string[]}) =>
publishThunk({event: makeComment(params), relays})
+1 -1
View File
@@ -30,7 +30,7 @@
}
onMount(() => {
editor = getEditor({autofocus: !isMobile, element, submit, uploading})
editor = getEditor({autofocus: !isMobile, element, submit, uploading, aggressive: true})
$editor!.chain().setContent(content).run()
})
+4 -1
View File
@@ -34,7 +34,10 @@
<div class="flex flex-col justify-start gap-1">
<div class="flex items-center justify-between gap-2">
<div class="flex min-w-0 items-center gap-2">
{#if others.length === 1}
{#if others.length === 0}
<ProfileCircle pubkey={$pubkey} size={5} />
Note to self
{:else if others.length === 1}
<ProfileCircle pubkey={others[0]} size={5} />
<ProfileName pubkey={others[0]} />
{:else}
+2 -1
View File
@@ -112,7 +112,8 @@
</div>
</Button>
{/if}
<span class="text-xs opacity-50">{formatTimestampAsTime(event.created_at)}</span>
<span class="whitespace-nowrap text-xs opacity-50"
>{formatTimestampAsTime(event.created_at)}</span>
</div>
{/if}
<div class="text-sm">
+4 -8
View File
@@ -1,7 +1,6 @@
<script lang="ts">
import {onMount} from "svelte"
import {first, sortBy, ctx} from "@welshman/lib"
import {getAncestorTags} from "@welshman/util"
import {ctx} from "@welshman/lib"
import type {Filter} from "@welshman/util"
import {deriveEvents} from "@welshman/store"
import {repository, load, loadRelaySelections, formatTimestampRelative} from "@welshman/app"
@@ -13,11 +12,9 @@
export let pubkey
const filters: Filter[] = [{authors: [pubkey]}]
const filters: Filter[] = [{authors: [pubkey], limit: 1}]
const events = deriveEvents(repository, {filters})
$: roots = $events.filter(e => getAncestorTags(e.tags).replies.length === 0)
onMount(async () => {
// Make sure we have their relay selections before we load their posts
await loadRelaySelections(pubkey)
@@ -39,10 +36,9 @@
</Link>
</div>
<ProfileInfo {pubkey} />
{#if roots.length > 0}
{@const event = first(sortBy(e => -e.created_at, roots))}
{#if $events.length > 0}
<div class="bg-alt badge badge-neutral border-none">
Last active {formatTimestampRelative(event.created_at)}
Last active {formatTimestampRelative($events[0].created_at)}
</div>
{/if}
<Link class="btn btn-primary sm:hidden" href={makeChatPath([pubkey])}>
+2 -2
View File
@@ -2,7 +2,7 @@
import {onMount} from "svelte"
import {sortBy, uniqBy} from "@welshman/lib"
import {feedFromFilter, makeIntersectionFeed, makeRelayFeed} from "@welshman/feeds"
import {NOTE, getAncestorTags} from "@welshman/util"
import {NOTE, getReplyTags} from "@welshman/util"
import type {TrustedEvent} from "@welshman/util"
import {createFeedController} from "@welshman/app"
import {createScroller} from "@lib/html"
@@ -22,7 +22,7 @@
feedFromFilter({kinds: [NOTE], authors: [pubkey]}),
),
onEvent: (event: TrustedEvent) => {
if (getAncestorTags(event.tags).replies.length === 0) {
if (getReplyTags(event.tags).replies.length === 0) {
buffer.push(event)
}
},
+12 -10
View File
@@ -36,16 +36,18 @@
)
onMount(() => {
load({
relays: [url],
filters: [{kinds: [REACTION, REPORT, DELETE], "#e": [event.id]}],
onEvent: batch(300, (events: TrustedEvent[]) => {
load({
relays: [url],
filters: [{kinds: [DELETE], "#e": events.map(e => e.id)}],
})
}),
})
if (url) {
load({
relays: [url],
filters: [{kinds: [REACTION, REPORT, DELETE], "#e": [event.id]}],
onEvent: batch(300, (events: TrustedEvent[]) => {
load({
relays: [url],
filters: [{kinds: [DELETE], "#e": events.map(e => e.id)}],
})
}),
})
}
})
</script>
+7
View File
@@ -26,6 +26,7 @@ export const signWithAssert = async (template: StampedEvent) => {
}
export const getEditor = ({
aggressive = false,
autofocus = false,
charCount,
content = "",
@@ -35,6 +36,7 @@ export const getEditor = ({
uploading,
wordCount,
}: {
aggressive?: boolean
autofocus?: boolean
charCount?: Writable<number>
content?: string
@@ -60,6 +62,11 @@ export const getEditor = ({
placeholder,
},
},
breakOrSubmit: {
config: {
aggressive,
},
},
fileUpload: {
config: {
onDrop() {
+11 -8
View File
@@ -421,19 +421,22 @@ export const chats = derived(
pushToMapKey(messagesByChatId, chatId, message)
}
const displayPubkey = (pubkey: string) => {
const profile = $profilesByPubkey.get(pubkey)
return profile ? displayProfile(profile) : ""
}
return sortBy(
c => -c.last_activity,
Array.from(messagesByChatId.entries()).map(([id, events]): Chat => {
const pubkeys = splitChatId(id)
const pubkeys = remove($pubkey!, splitChatId(id))
const messages = sortBy(e => -e.created_at, events)
const last_activity = messages[0].created_at
const search_text = remove($pubkey as string, pubkeys)
.map(pubkey => {
const profile = $profilesByPubkey.get(pubkey)
return profile ? displayProfile(profile) : ""
})
.join(" ")
const search_text =
pubkeys.length === 0
? displayPubkey($pubkey!) + " note to self"
: pubkeys.map(displayPubkey).join(" ")
return {id, pubkeys, messages, last_activity, search_text}
}),
+1 -1
View File
@@ -25,7 +25,7 @@
let term = ""
$: chats = $chatSearch.searchOptions(term).filter(c => c.pubkeys.length > 1)
$: chats = $chatSearch.searchOptions(term)
</script>
<SecondaryNav>
+1 -1
View File
@@ -17,7 +17,7 @@
const openMenu = () => pushModal(ChatMenuMobile)
$: chats = $chatSearch.searchOptions(term).filter(c => c.pubkeys.length > 1)
$: chats = $chatSearch.searchOptions(term)
onDestroy(() => {
setChecked($page.url.pathname)