diff --git a/package-lock.json b/package-lock.json index 35fc4c3d..75259af1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "flotilla", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "flotilla", - "version": "0.2.3", + "version": "0.2.4", "dependencies": { "@capacitor/android": "^6.1.2", "@capacitor/cli": "^6.1.2", @@ -30,16 +30,16 @@ "@types/qrcode": "^1.5.5", "@vite-pwa/assets-generator": "^0.2.6", "@vite-pwa/sveltekit": "^0.6.6", - "@welshman/app": "~0.0.37", + "@welshman/app": "~0.0.39", "@welshman/content": "~0.0.15", "@welshman/dvm": "~0.0.13", - "@welshman/editor": "~0.0.6", + "@welshman/editor": "~0.0.7", "@welshman/feeds": "~0.0.30", "@welshman/lib": "~0.0.37", "@welshman/net": "~0.0.45", "@welshman/signer": "~0.0.19", "@welshman/store": "~0.0.15", - "@welshman/util": "~0.0.57", + "@welshman/util": "~0.0.59", "daisyui": "^4.12.10", "date-picker-svelte": "^2.13.0", "dotenv": "^16.4.5", @@ -4843,9 +4843,9 @@ } }, "node_modules/@welshman/app": { - "version": "0.0.37", - "resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.37.tgz", - "integrity": "sha512-EhhLx10PE6r/soiuaR0GF+NSH9H3ilTaXwmfx2cHHR1PE2LXXvf1oWMJl0ZPFmYe0VWfNiu98SLbTLYwe1Y4dQ==", + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.39.tgz", + "integrity": "sha512-lEEG8Tp2TZLN1VfqR9JRJj2TtT16zozqaJBTMt6thggxVYxxFEGtLAyYA5s73kDqhvsTC/TlGoxt6a6OV5CLHw==", "license": "MIT", "dependencies": { "@types/throttle-debounce": "^5.0.2", @@ -4855,7 +4855,7 @@ "@welshman/net": "~0.0.45", "@welshman/signer": "~0.0.19", "@welshman/store": "~0.0.15", - "@welshman/util": "~0.0.54", + "@welshman/util": "~0.0.58", "fuse.js": "^7.0.0", "idb": "^8.0.0", "svelte": "^4.2.18", @@ -4902,9 +4902,9 @@ } }, "node_modules/@welshman/editor": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/@welshman/editor/-/editor-0.0.6.tgz", - "integrity": "sha512-7ZnjrsBX/5Z2OiHStCSBqNlspX/weURcP8yrH9CTcOEqJZfPx5UWfeYmzsbXttvCPBph+Cv9jfHkeVreyLkeKQ==", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@welshman/editor/-/editor-0.0.7.tgz", + "integrity": "sha512-dnhntOisr+mSTGH9DXFcH4gvKvs5XyAghucm2WwunlISNHgbFnUcAyUyrCnw5Fzuq5k8k8Fawf4K9bcfKAxDXw==", "peerDependencies": { "@tiptap/core": "^2.9.1", "@tiptap/extension-code": "^2.9.1", @@ -5004,9 +5004,9 @@ } }, "node_modules/@welshman/util": { - "version": "0.0.57", - "resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.57.tgz", - "integrity": "sha512-YflD6sfqdhIfHioJVlLydvyKOgACFL0dAcWHymlDz/FszIAl2k0XQXKgAjf0lT2uoXfrCdPsfSZwMTW7qUAY6Q==", + "version": "0.0.59", + "resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.59.tgz", + "integrity": "sha512-ACSwQqE0G4GSlHnW4Lbt1M1Wg8NVA5gQwod+fbH5+Z3d1RVtz8cKZvCsljaWT2bNyyi5xnh9B5E2ZfajexAxwQ==", "license": "MIT", "dependencies": { "@types/ws": "^8.5.13", diff --git a/package.json b/package.json index 38242db9..ecee9e86 100644 --- a/package.json +++ b/package.json @@ -59,16 +59,16 @@ "@types/qrcode": "^1.5.5", "@vite-pwa/assets-generator": "^0.2.6", "@vite-pwa/sveltekit": "^0.6.6", - "@welshman/app": "~0.0.37", + "@welshman/app": "~0.0.39", "@welshman/content": "~0.0.15", "@welshman/dvm": "~0.0.13", - "@welshman/editor": "~0.0.6", + "@welshman/editor": "~0.0.7", "@welshman/feeds": "~0.0.30", "@welshman/lib": "~0.0.37", "@welshman/net": "~0.0.45", "@welshman/signer": "~0.0.19", "@welshman/store": "~0.0.15", - "@welshman/util": "~0.0.57", + "@welshman/util": "~0.0.59", "daisyui": "^4.12.10", "date-picker-svelte": "^2.13.0", "dotenv": "^16.4.5", diff --git a/src/app/commands.ts b/src/app/commands.ts index b5c42ec6..42c855d3 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -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() +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}) diff --git a/src/app/components/ChannelCompose.svelte b/src/app/components/ChannelCompose.svelte index 8d254592..170b2e2b 100644 --- a/src/app/components/ChannelCompose.svelte +++ b/src/app/components/ChannelCompose.svelte @@ -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() }) diff --git a/src/app/components/ChatItem.svelte b/src/app/components/ChatItem.svelte index 877c3dc3..9ee2d6e2 100644 --- a/src/app/components/ChatItem.svelte +++ b/src/app/components/ChatItem.svelte @@ -34,7 +34,10 @@
- {#if others.length === 1} + {#if others.length === 0} + + Note to self + {:else if others.length === 1} {:else} diff --git a/src/app/components/ChatMessage.svelte b/src/app/components/ChatMessage.svelte index 6c652a82..df251293 100644 --- a/src/app/components/ChatMessage.svelte +++ b/src/app/components/ChatMessage.svelte @@ -112,7 +112,8 @@
{/if} - {formatTimestampAsTime(event.created_at)} + {formatTimestampAsTime(event.created_at)}
{/if}
diff --git a/src/app/components/PeopleItem.svelte b/src/app/components/PeopleItem.svelte index 05ce719d..87686ddd 100644 --- a/src/app/components/PeopleItem.svelte +++ b/src/app/components/PeopleItem.svelte @@ -1,7 +1,6 @@ diff --git a/src/app/editor/index.ts b/src/app/editor/index.ts index 9a45f5c0..cc6749f9 100644 --- a/src/app/editor/index.ts +++ b/src/app/editor/index.ts @@ -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 content?: string @@ -60,6 +62,11 @@ export const getEditor = ({ placeholder, }, }, + breakOrSubmit: { + config: { + aggressive, + }, + }, fileUpload: { config: { onDrop() { diff --git a/src/app/state.ts b/src/app/state.ts index 8f9798b1..b576e715 100644 --- a/src/app/state.ts +++ b/src/app/state.ts @@ -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} }), diff --git a/src/routes/chat/+layout.svelte b/src/routes/chat/+layout.svelte index 0b69b52d..9d845d4f 100644 --- a/src/routes/chat/+layout.svelte +++ b/src/routes/chat/+layout.svelte @@ -25,7 +25,7 @@ let term = "" - $: chats = $chatSearch.searchOptions(term).filter(c => c.pubkeys.length > 1) + $: chats = $chatSearch.searchOptions(term) diff --git a/src/routes/chat/+page.svelte b/src/routes/chat/+page.svelte index 2b3c209d..6c6085cf 100644 --- a/src/routes/chat/+page.svelte +++ b/src/routes/chat/+page.svelte @@ -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)