aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/features/messages.js41
-rw-r--r--src/style.css8
-rw-r--r--tools/feed-picture-pager-test.js16
3 files changed, 63 insertions, 2 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 8f8bdd4..245e1ce 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -7036,9 +7036,12 @@ export function messagesFeature(ctx) {
// make it): the server makes one
if (!got && (noCorsHost(url) || corsRefused.has(url) || typeof OffscreenCanvas === 'undefined')) got = await serverMediaThumb(url).catch(() => null);
if (got) {
+ // the grid tile made alongside it, for a post's run of pictures
+ // (see pictureRuns): looked up from disk when the copy was
+ await warmTileThumbs([url]).catch(() => {});
// no copy (small already, or a GIF): the original is what paints,
// so it's the one decoded ahead — the row mustn't decode it on sight
- await decodeAhead(got.thumb || url);
+ await Promise.all([decodeAhead(got.thumb || url), tileThumbs.has(url) ? decodeAhead(tileThumbs.get(url)) : null]);
mediaReady.set(url, got);
return;
}
@@ -10923,6 +10926,7 @@ export function messagesFeature(ctx) {
// opens the thread — not on the picture.
function onPicture(e) {
const el = e.currentTarget;
+ if (el.closest('.note-gallery')) return true; // a gallery tile is all picture (cropped to fill)
const r = el.getBoundingClientRect();
const nw = el.naturalWidth, nh = el.naturalHeight;
if (!nw || !nh || !r.width || !r.height) return true;
@@ -10953,7 +10957,7 @@ export function messagesFeature(ctx) {
// height-capped: see .note-img)
const known = size || mediaReady.get(url);
return h('img', {
- src: mediaSrc(url, known), class: 'note-img clickable', loading: feedPaint || known ? 'eager' : 'lazy', alt: label || '',
+ src: mediaSrc(url, known), 'data-pic': url, class: 'note-img clickable', loading: feedPaint || known ? 'eager' : 'lazy', alt: label || '',
// a few-ms decode of the copy paints with the page; an original never holds the page for its decode
decoding: known && known.thumb ? 'sync' : 'async',
width: size?.width, height: size?.height,
@@ -11381,6 +11385,39 @@ export function messagesFeature(ctx) {
for (const p of splitEmoji(part, emojiAt)) out.push(...(typeof p === 'string' ? mdInline(p) : [emojiImg(p.code, p.url)]));
} else out.push(...mdInline(part));
}
+ return pictureRuns(out);
+ }
+ // Two or more pictures in a row (only blank space between them) share one
+ // box of justified rows, the way the Images feed lays them out, instead of
+ // a screen each: a post of thirteen photos was thirteen screens to scroll
+ // past ("could we put them into a masonry grid layout within the post kinda
+ // like we do on our images feed", Adam, 2026-11-18). A tap still opens the
+ // picture in the pager, with the rest a swipe away.
+ const isNoteImg = (n) => !!n && n.nodeType === 1 && n.tagName === 'IMG' && n.classList.contains('note-img');
+ function pictureRuns(nodes) {
+ const out = [];
+ for (let i = 0; i < nodes.length; i++) {
+ if (!isNoteImg(nodes[i])) { out.push(nodes[i]); continue; }
+ const run = [nodes[i]];
+ let j = i + 1, last = i;
+ for (; j < nodes.length; j++) {
+ const n = nodes[j];
+ if (isNoteImg(n)) { run.push(n); last = j; continue; }
+ if (typeof n === 'string' && !n.trim()) continue;
+ break;
+ }
+ if (run.length < 2) { out.push(nodes[i]); continue; }
+ // A tile is painted from the Images feed's tile copy (360px, cut with a
+ // proper resize), not the 1100px column copy: shrunk eight times by the
+ // browser, that came out grainy (Adam, 2026-11-18).
+ for (const img of run) {
+ const url = img.getAttribute('data-pic'), tile = url && tileThumbs.get(url);
+ if (tile) img.setAttribute(img.hasAttribute('data-lazy-src') ? 'data-lazy-src' : 'src', tile);
+ else if (url && /^https?:/i.test(url)) queueTileThumbs([url]);
+ }
+ out.push(h('div', { class: 'note-gallery' }, ...run));
+ i = last;
+ }
return out;
}
diff --git a/src/style.css b/src/style.css
index f036fb8..a9ceadb 100644
--- a/src/style.css
+++ b/src/style.css
@@ -1631,6 +1631,14 @@ body::after {
320px would widen its tile, and the row's height with it */
.media-grid.justified .media-tile > img, .media-grid.justified .media-tile > video { position: absolute; inset: 0; }
@media (max-width: 600px) { .media-grid.justified { --row-h: 100px; } }
+/* a post's run of pictures: the same justified rows, inside the post */
+.note-gallery { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; border-radius: 10px; overflow: hidden; --row-h: 140px; }
+.note-gallery::after { content: ''; flex: 1000 1 0; }
+.note-gallery .note-img, .note-gallery .note-img.note-img-late {
+ margin: 0; border-radius: 0; width: auto; height: auto; max-width: none; max-height: none; min-width: 0;
+ aspect-ratio: var(--ar, 1); flex: var(--ar, 1) 1 calc(var(--ar, 1) * var(--row-h)); object-fit: cover; cursor: zoom-in;
+}
+@media (max-width: 600px) { .note-gallery { --row-h: 100px; } }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.media-tile.broken { display: none; }
.media-tile-play {
diff --git a/tools/feed-picture-pager-test.js b/tools/feed-picture-pager-test.js
index f74c981..947c6aa 100644
--- a/tools/feed-picture-pager-test.js
+++ b/tools/feed-picture-pager-test.js
@@ -82,6 +82,22 @@ try {
await waitText('receive', 20000);
await page.evaluate(() => document.querySelector('.app-nav-button[aria-label="Feed"]').click());
check('the pictures are in the feed', await waitFor(() => document.querySelectorAll('.notes-feed img.note-img').length >= 4, null, 20000));
+ // a post's run of pictures shares one box of justified rows (the Images
+ // feed's layout), not a screen each; a lone picture stays as it was
+ const gal = await page.evaluate(() => {
+ const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes('two pictures'));
+ const one = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.textContent.includes('one picture'));
+ const g = r && r.querySelector('.note-gallery');
+ const im = g ? [...g.querySelectorAll('img.note-img')].map((i) => i.getBoundingClientRect()) : [];
+ return { n: im.length, sameRow: im.length === 2 && Math.abs(im[0].top - im[1].top) < 1 && Math.abs(im[0].height - im[1].height) < 1.5, h: im[0] ? Math.round(im[0].height) : 0, lone: !!one && !one.querySelector('.note-gallery') && !!one.querySelector('img.note-img') };
+ });
+ check('two pictures in a post: one gallery, side by side, one height', gal.n === 2 && gal.sameRow && gal.h > 50 && gal.h < 300, JSON.stringify(gal));
+ check('a lone picture is not put in a gallery', gal.lone);
+ // painted from the tile copy (a proper resize), not the column copy shrunk by the browser
+ check('gallery tiles are painted from the tile copies', await waitFor(() => {
+ const g = document.querySelector('.notes-feed .note-gallery');
+ return !!g && [...g.querySelectorAll('img')].every((i) => /^blob:/.test(i.currentSrc || i.src) && i.naturalHeight > 0 && i.naturalHeight <= 360);
+ }, null, 5000));
console.log('\n[a tap on the picture that opened it shows its details; the next closes it]');
const y0 = await openPic('two pictures');