From c2d190e107050ebe705c632e7288b240980413d5 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 9 Mar 2026 13:00:56 -0400 Subject: [PATCH] fix: update thumbs loading logic to always include post attachments as part of thumbs (prior: was controlled by thumbsOnly flag orshowPostUploadsAsThumbnail setting) --- src/topics/thumbs.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/topics/thumbs.js b/src/topics/thumbs.js index 013e82a483..123f84f026 100644 --- a/src/topics/thumbs.js +++ b/src/topics/thumbs.js @@ -45,13 +45,22 @@ Thumbs.load = async function (topicData, options = {}) { async function loadFromTopicData(topicData, options = {}) { const tids = topicData.map(t => t && t.tid); const thumbs = topicData.map(t => t && Array.isArray(t.thumbs) ? t.thumbs : []); + const mainPids = topicData.map(t => t.mainPid); + + const mainPidAttachments = await posts.attachments.get(mainPids); + // Add attachments to thumb sets + mainPidAttachments.forEach((attachments, idx) => { + attachments = attachments.filter( + attachment => !thumbs[idx].includes(attachment.url) && (attachment.mediaType && attachment.mediaType.startsWith('image/')) + ); + + if (attachments.length) { + thumbs[idx].push(...attachments.map(attachment => attachment.url)); + } + }); if (!options.thumbsOnly) { - const mainPids = topicData.map(t => t.mainPid); - const [mainPidUploads, mainPidAttachments] = await Promise.all([ - posts.uploads.list(mainPids), - posts.attachments.get(mainPids), - ]); + const mainPidUploads = await posts.uploads.list(mainPids); // Add uploaded media to thumb sets mainPidUploads.forEach((uploads, idx) => { @@ -64,17 +73,6 @@ async function loadFromTopicData(topicData, options = {}) { thumbs[idx].push(...uploads); } }); - - // Add attachments to thumb sets - mainPidAttachments.forEach((attachments, idx) => { - attachments = attachments.filter( - attachment => !thumbs[idx].includes(attachment.url) && (attachment.mediaType && attachment.mediaType.startsWith('image/')) - ); - - if (attachments.length) { - thumbs[idx].push(...attachments.map(attachment => attachment.url)); - } - }); } const hasTimestampPrefix = /^\d+-/;