Plugin For Read/Unread in Groups?
-
Correct me if I'm wrong, but I don't think nodebb supports read/unread logic in groups out of the box. Is it possible to add this via plugin ?
-
@baris similar to topics list in category view, when there is a new topic that you haven't read, the color of the font shows blue (depending on your theme). All read topics are in black. I believe there is a logic somewhere that adds an 'unread' class to the element that changes the color of the font, but I don't know if this is possible to the posts/topics found in the group page.
-
It is not possible out of the box since that logic only works on lists of topics and not posts(group page is displaying posts). A plugin can do it by looking at the topics of those posts and determine if they are read/unread and alter the template.
-
That hook is triggered on other places as well. If you only want to do this modification on the groups page. I suggest you use the hook
filter:groups/details.build
. The same data is available intemplateData
myPlugin.filterGroupsDetailsBuild = async (hookData) => { console.log(hookData.templateData); return hookData; };
-
@baris can't seem to access 'topic' under posts. Can you tell me what's wrong with me code?
myPlugin.filterGroupsDetailsBuild = async (hookData) => { const pids = hookData.templateData.posts.map(t => t.pid); const getTopic = await topics.getUnreadData(pids); hookData.templateData.posts.forEach((t, i) => { t.foobar = getTopic[i]; }); return hookData; };