Home > Back-end >  add children comments to parent comment array
add children comments to parent comment array

Time:11-20

Long story short, I have to implement a comments view controller with nested comments (1 level) following this structure:

  -- Comment
     -- reply to comment 
     -- reply to comment 
  -- Comment 
  -- Comment

I had asked the backend if they could provide an optional array of children comments (let children[Comment]?) inside so, when I delete the parent in the collection view cell, I don't have to wait for the backend to reload data, removing the object from the current data source.

Instead the Backend came up with this json where you can understand which is the parent if the id and the root_comment_id are the same. If not, all the subsequent comments belong to the first object.

  • Related