diff options
| author | Adam Soltys <[email protected]> | 2026-10-23 17:03:45 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-23 17:03:45 -0700 |
| commit | b67ad2026286f6383f24b1aa9694bbeee571276b (patch) | |
| tree | 4e0d24d889d0709475250dd2914ac2d89ea95546 /src | |
| parent | 4efc64bee92900cf9fe53998837fc0e39d8c943e (diff) | |
| download | coinosv3-b67ad2026286f6383f24b1aa9694bbeee571276b.tar.gz coinosv3-b67ad2026286f6383f24b1aa9694bbeee571276b.zip | |
The media grid's order holds for the session: clips found later go under the tiles already showing, in their own date order; only a post newer than the top tile goes above it
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QjVvE4YAcK3AGwV7kZXeN4
Diffstat (limited to 'src')
| -rw-r--r-- | src/features/messages.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index dea454c..a35c0da 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -13498,7 +13498,9 @@ export function messagesFeature(ctx) { const key = mediaIdxKey(feedId); let r = mediaIdx.get(key); if (r) return r; - r = { key, replies: !!(feedDef(feedId) || {}).replies, images: new Map(), videos: new Map(), articles: new Map(), art: { until: 0, end: 0, empty: 0, head: 0 }, checked: new Set(), until: 0, end: false, empty: 0, loaded: false }; + const order = () => ({ seq: new Map(), top: 0, bottom: 0, newest: 0 }); + r = { key, replies: !!(feedDef(feedId) || {}).replies, images: new Map(), videos: new Map(), articles: new Map(), art: { until: 0, end: 0, empty: 0, head: 0 }, checked: new Set(), until: 0, end: false, empty: 0, loaded: false, + order: { images: order(), videos: order() } }; mediaIdx.set(key, r); loadMediaIndex(key).then(async (rec) => { if (rec) { @@ -14037,7 +14039,27 @@ export function messagesFeature(ctx) { out.push({ ev, url }); } } - return out; + return settledOrder(r, kind, out); + } + // The grid's order holds for the session (Adam, 2026-10-23: clips the + // crawl found landed in the middle of the grid, above an older tail the + // index had from before, and the tiles already there jumped): what it + // shows first is newest first, and whatever turns up after goes under what + // is already there, in its own date order. Only a post newer than the top + // tile goes above it. Nothing is settled until the kept index is in, so + // the first paint is one date order, not two batches. + function settledOrder(r, kind, out) { + if (!r.loaded) return out; + const o = r.order[kind]; + const key = (it) => it.ev.id + '|' + it.url; + const fresh = out.filter((it) => !o.seq.has(key(it))); + if (fresh.length) { + const above = o.seq.size ? fresh.filter((it) => it.ev.created_at > o.newest) : []; + for (const it of above.reverse()) o.seq.set(key(it), --o.top); + for (const it of fresh) if (!o.seq.has(key(it))) o.seq.set(key(it), ++o.bottom); + for (const it of fresh) if (it.ev.created_at > o.newest) o.newest = it.ev.created_at; + } + return out.sort((a, b) => o.seq.get(key(a)) - o.seq.get(key(b))); } // The feed's pictures (or clips) in reading order — every one of a post // before the next post's — for the pager opened from one in the feed: the |
