Troubleshooting recent cards plugin not showing any topics
Solved
Technical Support
-
checkVisibility { cid: '', topicsFromCid: '', topicsTids: '', teaserPost: 'last-post', sort: 'recent', title: '', container: '', groups: [ 'administrators', 'all' ], startDate: '', endDate: '', groupsHideFrom: [] } true false is widget visible? recentCards true how many topics? 0 is recent cards rendered ? is widget renderered? recentCards is widget translated? recentCards 1
-
@DownPW looks like 0 topics are loaded for your user account, now in the same file there is another function called
getTopics
replace it with the below and let me know the output.async function getTopics(widget) { async function getTopicsFromSet(set, start, stop) { let tids = await db.getSortedSetRevRangeByScore(set, start, stop, Date.now(), '-inf'); tids = await topics.filterNotIgnoredTids(tids, widget.uid); let topicsData = await topics.getTopics(tids, { uid: widget.uid, teaserPost: widget.data.teaserPost || 'first', }); topicsData = await user.blocks.filter(widget.uid, topicsData); return { topics: topicsData }; } let topicsData = { topics: [], }; let filterCids = getIdsArray(widget.data, 'topicsFromCid'); if (!filterCids.length && widget.templateData.cid) { filterCids = [parseInt(widget.templateData.cid, 10)]; } widget.data.sort = widget.data.sort || 'recent'; let fromGroups = widget.data.fromGroups || []; if (fromGroups && !Array.isArray(fromGroups)) { fromGroups = [fromGroups]; } // hard coded to show these topic tids only const topicsTids = getIdsArray(widget.data, 'topicsTids'); if (topicsTids.length) { topicsData.topics = await topics.getTopics(topicsTids, { uid: widget.uid, teaserPost: widget.data.teaserPost || 'first', }); } else if (fromGroups.length) { const uids = _.uniq(_.flatten(await groups.getMembersOfGroups(fromGroups))); const sets = uids.map((uid) => { if (filterCids.length) { return filterCids.map(cid => `cid:${cid}:uid:${uid}:tids`); } return `uid:${uid}:topics`; }); topicsData = await getTopicsFromSet(sets.flat(), 0, 19); topicsData.topics.sort((t1, t2) => { if (widget.data.sort === 'recent') { return t2.lastposttime - t1.lastposttime; } else if (widget.data.sort === 'votes') { return t2.votes - t1.votes; } else if (widget.data.sort === 'posts') { return t2.postcount - t1.postcount; } return 0; }); } else if (filterCids.length) { let searchSuffix = ''; if (widget.data.sort === 'recent') { searchSuffix += ':lastposttime'; } else if (widget.data.sort === 'votes' || widget.data.sort === 'posts') { searchSuffix += `:${widget.data.sort}`; } topicsData = await getTopicsFromSet( filterCids.map(cid => `cid:${cid}:tids${searchSuffix}`), 0, 19 ); } else { topicsData = await topics.getSortedTopics({ uid: widget.uid, start: 0, stop: 19, sort: widget.data.sort, teaserPost: widget.data.teaserPost || 'first', }); console.log(' loaded topics =>', topicsData.topics.length); // filter out scheduled topicsData.topics = topicsData.topics.filter(t => t && !t.scheduled); console.log(' scheduled topics filtered =>', topicsData.topics.length); } let i = 0; const cids = []; let finalTopics = []; if (!plugin.settings.get('enableCarousel')) { while (finalTopics.length < 4 && i < topicsData.topics.length) { const cid = parseInt(topicsData.topics[i].cid, 10); if (filterCids.length || !cids.includes(cid)) { cids.push(cid); finalTopics.push(topicsData.topics[i]); } i += 1; } } else { finalTopics = topicsData.topics; } console.log(' finalsTopics =>', finalTopics.length); return finalTopics; }
-
checkVisibility { cid: '', topicsFromCid: '', topicsTids: '', teaserPost: 'last-post', sort: 'recent', title: '', container: '', groups: [ 'administrators', 'all' ], startDate: '', endDate: '', groupsHideFrom: [] } true false is widget visible? recentCards true loaded topics => 20 scheduled topics filtered => 0 finalsTopics => 0 how many topics? 0 is recent cards rendered ? is widget renderered? recentCards is widget translated? recentCards 1
-
Yeah that's why, recent cards plugin is loading the most recent 20 topics and then filtering the ones that are scheduled since you have more than 20, nothing is left to display. I will make small change in recent-cards plugin so it loads more if they are all scheduled.
-
wow fast
Test this version now -
OK, do it know and tell you without publish scheduled topics.
-
Seems to work yeahhhh
-
Copyright © 2024 NodeBB | Contributors