VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
404 stars 63 forks source link

[CU-86934hmxa] return root thread comments use pagination #238

Open glacierck opened 7 months ago

glacierck commented 7 months ago

The current flat structure returns no application value, it is like a journal. And the tree structure does not have pagination function and has no engineering significance

Each descendant comment should record their root comment ID, so that we can perform pagination queries on the root comment and recall the N levels of descendant comments below each root comment。

cyp3rius commented 7 months ago

Is it worth to introduce startWith property if undefined then its root, otherwise take the id of comment to build the nested structure starting with it?

glacierck commented 7 months ago

The advantage of this is that it is easy to build a comment view with only two layers. The first layer is the root comment, which is oriented towards the comment object (article), and the second layer is the reply to the comment, with the reply target being the root comment or other reply. Similar to the following view:

comment:

glacierck commented 7 months ago

To achieve such a view, we only need to maintain two relationships for comments: the root relationship and the reply relationship. Of course, as root comments, they can be set null (when the reply target is a root comment, it is possible to only maintain the root relationship without filling in the reply relationship. In this case, they are the same)