Node.js based forum software built for the modern web
fix: #8763
Barış Soner Uşaklı331d236f6e15
diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.jsindex 6b433ea00a..9e065b73b8 100644--- a/src/controllers/accounts/profile.js+++ b/src/controllers/accounts/profile.js@@ -82,9 +82,23 @@ async function getBestPosts(callerUid, userData) {async function getPosts(callerUid, userData, setSuffix) {const cids = await categories.getCidsByPrivilege('categories:cid', callerUid, 'topics:read');const keys = cids.map(c => 'cid:' + c + ':uid:' + userData.uid + ':' + setSuffix);- const pids = await db.getSortedSetRevRange(keys, 0, 9);- const postData = await posts.getPostSummaryByPids(pids, callerUid, { stripTags: false });- return postData.filter(p => p && !p.deleted && p.topic && !p.topic.deleted);+ let hasMorePosts = true;+ let start = 0;+ const count = 10;+ const postData = [];+ do {+ /* eslint-disable no-await-in-loop */+ const pids = await db.getSortedSetRevRange(keys, start, start + count - 1);+ if (!pids.length || pids.length < count) {+ hasMorePosts = false;+ }+ if (pids.length) {+ const p = await posts.getPostSummaryByPids(pids, callerUid, { stripTags: false });+ postData.push(...p.filter(p => p && !p.deleted && p.topic && !p.topic.deleted));+ }+ start += count;+ } while (postData.length < count && hasMorePosts);+ return postData.slice(0, count);}function addMetaTags(res, userData) {