aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/features/messages.js26
-rw-r--r--src/style.css8
-rw-r--r--tools/feed-picture-pager-test.js11
3 files changed, 45 insertions, 0 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 8f8bdd4..a254295 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -10923,6 +10923,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;
@@ -11381,6 +11382,31 @@ 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; }
+ 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..7578e01 100644
--- a/tools/feed-picture-pager-test.js
+++ b/tools/feed-picture-pager-test.js
@@ -82,6 +82,17 @@ 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);
console.log('\n[a tap on the picture that opened it shows its details; the next closes it]');
const y0 = await openPic('two pictures');