From 2e8fd12ec780ed8314c54c030eabc67be0e11678 Mon Sep 17 00:00:00 2001 From: dawn <90008@gaze.systems> Date: Fri, 2 Jan 2026 05:28:14 +0300 Subject: [PATCH] show replying to / quoting inside the collapsed composer as well --- src/components/BskyPost.svelte | 16 +++++--- src/components/PostComposer.svelte | 60 ++++++++++++++++++++++------ src/components/ProfileInfo.svelte | 20 +++++++--- src/components/ProfilePicture.svelte | 39 +++++++----------- src/components/ProfileView.svelte | 19 ++++++--- src/lib/cache.ts | 4 +- src/lib/state.svelte.ts | 7 +++- 7 files changed, 108 insertions(+), 57 deletions(-) diff --git a/src/components/BskyPost.svelte b/src/components/BskyPost.svelte index 80c62da..5b379dc 100644 --- a/src/components/BskyPost.svelte +++ b/src/components/BskyPost.svelte @@ -9,8 +9,8 @@ } from '@atcute/bluesky'; import { parseCanonicalResourceUri, - type ActorIdentifier, type Did, + type Handle, type RecordKey, type ResourceUri } from '@atcute/lexicons'; @@ -28,7 +28,9 @@ findBacklinksBy, deletePostBacklink, createPostBacklink, - router + router, + profiles, + handles } from '$lib/state.svelte'; import type { PostWithUri } from '$lib/at/fetch'; import { onMount, type Snippet } from 'svelte'; @@ -76,19 +78,23 @@ const aturi = $derived(toCanonicalUri({ did, collection: 'app.bsky.feed.post', rkey })); const color = $derived(generateColorForDid(did)); - let handle: ActorIdentifier = $state('handle.invalid'); + let handle: Handle = $state(handles.get(did) ?? 'handle.invalid'); const didDoc = resolveDidDoc(did).then((res) => { - if (res.ok) handle = res.value.handle; + if (res.ok) { + handle = res.value.handle; + handles.set(did, handle); + } return res; }); const post = data ? Promise.resolve(ok(data)) : client.getRecord(AppBskyFeedPost.mainSchema, did, rkey); - let profile: AppBskyActorProfile.Main | null = $state(null); + let profile: AppBskyActorProfile.Main | null = $state(profiles.get(did) ?? null); onMount(async () => { const p = await client.getProfile(did); if (!p.ok) return; profile = p.value; + profiles.set(did, profile); // console.log(profile.description); }); diff --git a/src/components/PostComposer.svelte b/src/components/PostComposer.svelte index d879aa2..a6e54b6 100644 --- a/src/components/PostComposer.svelte +++ b/src/components/PostComposer.svelte @@ -10,6 +10,7 @@ import { parseToRichText } from '$lib/richtext'; import { tokenize } from '$lib/richtext/parser'; import Icon from '@iconify/svelte'; + import ProfilePicture from './ProfilePicture.svelte'; export type FocusState = 'null' | 'focused'; export type State = { @@ -40,7 +41,6 @@ uri: p.uri }); - // Parse rich text (mentions, links, tags) const rt = await parseToRichText(text); const record: AppBskyFeedPost.Main = { @@ -120,13 +120,34 @@ {/snippet} {/snippet} +{#snippet attachmentIndicator(post: PostWithUri, type: 'quoting' | 'replying')} + {@const parsedUri = expect(parseCanonicalResourceUri(post.uri))} + {@const color = generateColorForDid(parsedUri.repo)} +
+ + {type === 'replying' ? 'replying to' : 'quoting'} + +
+ +
+
+{/snippet} + {#snippet highlighter(text: string)} {#each tokenize(text) as token, idx (idx)} {@const highlighted = @@ -216,7 +237,7 @@ : `color-mix(in srgb, color-mix(in srgb, var(--nucleus-bg) 85%, ${color}) 70%, transparent)`}; border-color: color-mix(in srgb, {color} {isFocused ? '100' : '40'}%, transparent);" > -
+
{#if info.length > 0}
(_state.focus = 'focused')} - type="text" - placeholder="what's on your mind?" - class="flex-1" - /> + +
{ + if (e.defaultPrevented) return; + _state.focus = 'focused'; + }} + > + {#if _state.replying} + {@render attachmentIndicator(_state.replying, 'replying')} + {/if} + (_state.focus = 'focused')} + type="text" + placeholder="what's on your mind?" + class="min-w-0 flex-1 border-none bg-transparent outline-none placeholder:text-(--nucleus-fg)/45 focus:ring-0" + /> + {#if _state.quoting} + {@render attachmentIndicator(_state.quoting, 'quoting')} + {/if} +
{/if}
{/if} @@ -253,7 +289,7 @@ } .composer { - @apply p-2; + @apply p-1; } textarea { @@ -261,7 +297,7 @@ } input { - @apply p-1 px-2; + @apply p-1.5; } .composer { diff --git a/src/components/ProfileInfo.svelte b/src/components/ProfileInfo.svelte index 14f8eb1..7bcef4c 100644 --- a/src/components/ProfileInfo.svelte +++ b/src/components/ProfileInfo.svelte @@ -1,31 +1,41 @@ -