From a91155b1904384a8b2f151a9c50df06ad068a397 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 17 Nov 2026 13:14:04 -0700 Subject: A draft's Preview shows a link as its card. "i added metadata to paff pages, was hoping links to movies would render with a nicely formatted thumbnail" (Adam, 2026-11-17). The registrar already reads paff.club's movie pages (title "Hackers (1995) · from 1:21:50", description, backdrop), and a posted note warms its links' cards before it shows; the composer's Preview ran the same renderer but never asked for the page, so a link not already cached stayed a bare URL. It now asks once the typing settles (half a second), then repaints into the card. link-preview-test (a draft's preview shows the movie card, asked once) and compose-preview-test pass. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6SwkivduFDDkMmnXjZ --- src/features/messages.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/features/messages.js') diff --git a/src/features/messages.js b/src/features/messages.js index 95fcde8..6875856 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -14099,8 +14099,21 @@ export function messagesFeature(ctx) { // You could only find out by posting. This runs the draft through noteBody // — the very renderer the feed uses — so the preview is not a lookalike of // the real thing, it IS the real thing. + // A link's card needs its page read first: the feed warms that before a + // post shows, a draft only once the typing settles (not one registrar call + // per keystroke of a URL), then repaints into the card. + let draftPvTimer = null; + function warmDraftPreviews(body) { + const want = notePreviewUrls(body).filter((u) => !previews.has(u)); + clearTimeout(draftPvTimer); + if (!want.length) return; + draftPvTimer = setTimeout(() => { + for (const u of want) warmPreview(u).then(() => { if (previews.get(u)) scheduleRepaint(); }); + }, 500); + } function draftPreview(text) { const body = String(text || '').trim(); + warmDraftPreviews(body); return h('div', { class: 'draft-preview' }, h('div', { class: 'draft-preview-tag' }, t('composePreviewTag')), body -- cgit v1.2.3