diff options
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/messages.js | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 7be3630..4900c40 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -13946,8 +13946,14 @@ export function messagesFeature(ctx) { if (d && d.probed && !d.w && d.ranges && !videoDims.has(url)) return playerShape(url); }).finally(() => { if (mediaMode === 'videos') scheduleRepaint(); }); } + // One picture or clip shows once in the grid, however many posts carry it + // (Adam, 2026-10-22: a conference promo filled the Videos view with + // copies): the same file (a Blossom hash names it wherever it's hosted), + // or the same words from the same person posted again with another upload. + const sameFile = (url) => { const m = /\/([0-9a-f]{64})(?:\.\w+)?(?:[?#]|$)/i.exec(url); return m ? m[1].toLowerCase() : url.replace(/[?#].*$/, ''); }; + const saidAgain = (ev) => { const w = String(ev.content || '').replace(/https?:\/\/\S+/g, '').replace(/\s+/g, ' ').trim(); return w.length >= 8 ? ev.pubkey + '|' + w : null; }; function mediaItems(c, kind) { - const out = [], seen = new Set(); + const out = [], seen = new Set(), said = new Map(); const r = mediaIndex(c.id); indexMedia(r, c.notes); const evs = [...r[kind].values()].sort((a, b) => b.created_at - a.created_at); @@ -13956,14 +13962,19 @@ export function messagesFeature(ctx) { if (hidden(ev)) continue; // a grid shows the picture itself — no warning to fold it behind if (curated ? notForPublic(ev) : modOn('sensitive') && sensitiveWhy(ev) !== null && !isMe(ev.pubkey)) continue; + const again = saidAgain(ev); + if (again && said.has(again) && said.get(again) !== ev.id) continue; if (kind === 'videos') learnVideoMeta(ev); const urls = kind === 'videos' ? clipUrlsOf(ev).filter(fitClip) : noteMediaUrls(ev.content).filter((u) => !u.startsWith('https://i.ytimg.com/')); + // (the words are taken by a post that shows: one whose clip doesn't fit + // the screen leaves them to the next) + if (again && urls.length) said.set(again, ev.id); for (const url of urls) { - const it = { ev, url }; - if (seen.has(mediaKey(it))) continue; - seen.add(mediaKey(it)); - out.push(it); + const f = sameFile(url); + if (seen.has(f)) continue; + seen.add(f); + out.push({ ev, url }); } } return out; @@ -14485,6 +14496,7 @@ export function messagesFeature(ctx) { m.closest('.mp-slide').classList.add('mp-gone'); m.insertAdjacentElement('afterend', h('div', { class: 'mp-missing' }, h('div', { class: 'mp-missing-ico' }, '🖼'), h('div', {}, t('mediaPicGone')), host ? h('div', { class: 'small muted' }, host) : null)); } })); + if (video) capUpscale(media); const caption = mediaCaption(ev, true); const stop = (fn) => (e) => { e.stopPropagation(); fn(e); }; const slide = h('div', { class: 'mp-slide', 'data-k': mediaKey(it) }, @@ -14537,6 +14549,23 @@ export function messagesFeature(ctx) { // (the clip holds still meanwhile, and the time shows); the drag is the // bar's alone, never the pager's swipe or its tap. const clock = (t) => { t = Math.max(0, Math.floor(t || 0)); const m = Math.floor(t / 60), x = t % 60; return m + ':' + String(x).padStart(2, '0'); }; + // A big screen blew a small clip up into blocks (Adam, 2026-10-22: "videos + // that are low res … so pixellated on my large 1920 monitor"). In a big + // window (a phone on its side is too short) a clip is drawn at most 1.5× + // its own pixels, + // smaller ones sitting in the middle on the pager's black. A phone fills + // its screen as before. + const MAX_UPSCALE = 1.5; + function capUpscale(v) { + const fit = () => { + const big = v.videoWidth && matchMedia('(min-width: 1000px) and (min-height: 600px)').matches; + const k = MAX_UPSCALE / (window.devicePixelRatio || 1); + v.style.maxWidth = big ? Math.round(v.videoWidth * k) + 'px' : ''; + v.style.maxHeight = big ? Math.round(v.videoHeight * k) + 'px' : ''; + }; + v.addEventListener('loadedmetadata', fit); + if (v.readyState >= 1) fit(); + } // up for a few seconds, and on while a finger is on it // (a mouse brings it up by moving, so it goes sooner once the mouse is // still, and stays while the pointer rests on the bar itself) |
