Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960// Renders a single normalized activity entry into an AIM IM-window line.// `ctx` carries the resolve maps: ctx.posts (uri -> post view) and// ctx.profiles (did -> profile view), filled by chat.js before rendering.
import { esc, clip, shortDid, fmtTime, postUrl } from './util.js';
const VERB = { block: 'blocked someone', profile: 'updated their profile', other: 'did something',};
// The quote block. When we can build a bsky.app URL for the post, it becomes a// clickable link to that post; otherwise a plain div.function quote(txt, who, uri) { const w = who ? `<span class="q-who">@${esc(who)}</span> ` : ''; const inner = `${w}${txt ? esc(clip(txt)) : '<i>(no text)</i>'}`; const url = postUrl(uri); return url ? `<a class="q q-link" href="${esc(url)}" target="_blank" rel="noopener">${inner}</a>` : `<div class="q">${inner}</div>`;}
function bodyHtml(e, ctx) { switch (e.kind) { case 'post': case 'reply': return `<span class="verb">${e.kind === 'reply' ? 'replied' : 'posted'}</span>` + quote(e.text + (e.img ? ' 🖼' : ''), null, e.uri); case 'repost': { const tgt = e.targetUri ? ctx.posts[e.targetUri] : null; return `<span class="verb">🔁 reposted</span>` + quote(e.text || tgt?.record?.text || '', e.targetHandle || tgt?.author?.handle, e.uri); } case 'like': { const tgt = e.targetUri ? ctx.posts[e.targetUri] : null; return `<span class="verb">❤ liked</span>` + quote(tgt?.record?.text || '', tgt?.author?.handle, e.uri); } case 'follow': { const p = e.targetDid ? ctx.profiles[e.targetDid] : null; const h = p?.handle || e.targetHandle || (e.targetDid ? shortDid(e.targetDid) : 'someone'); return `<span class="verb">➕ followed</span> <span class="q-who">@${esc(h)}</span>`; } default: return `<span class="verb">${VERB[e.kind] || 'did something'}</span>`; }}
export function lineHtml(buddy, e, ctx) { const isMe = e.dir === 'me'; const name = isMe ? 'you' : (buddy.profile?.displayName?.trim() || buddy.profile?.handle || 'buddy'); const t = e.timeMs ? fmtTime(e.timeMs) : ''; return `<div class="im-line${isMe ? ' mine' : ''}"> <span class="im-name">${esc(name)}</span> <span class="im-time">${t}</span> <div class="im-body">${bodyHtml(e, ctx)}</div> </div>`;}