Discussions Data flowThis is how the discussions panels work on Seed

    This document describes how we are fetching, processing and rendering discussions and comments on both apps for the three ways we render the discussions panel: All Discussions, Discussions for a Document Block and Replies for a Discussion

    This exercise will help me understand what is the work needed to render the current discussion panel and how I can unify the logic so both apps can use the same and make the codebase easier to maintain

    All Discussions

      Only render the top-level comments for each target (document)

      Desktop App

        get all comments from backend (useAllDiscussions)

        get all comment groups (useCommentGroups)

        get all authors from all comments (useCommentGroupAuthors)

        get current selected account (useSelectedAccountId)

        render all the comment groups ()

      Web app

        get all comments from backend (useAllDiscussions)

        get all comment groups (useAllDiscussions already gives the commentGroups)

        the authors are also handled by useAllDiscussions

        render all the comment groups ()

    Discussions for a Block (Comment block Citation)

      Only render all comments that target a specific block ID

      Desktop app

        get all document citations (useDocumentCitations)

        filter the citations to that specific block and that are comments

        get all authors from filtered citations

        render all filtered citations () + quoted block

      Web App

        get all document citations (listEntityMentions)

        iterate over all citations

          filter only comment citations

          get all the comments

          get all the authors

          return the comments with the authors

        render all comment citations () + quoted block

    Replies for a Discussion (Comment Replies)

      Only render direct replies of a particular comment

      Desktop App

        get all comments (useAllDiscussions)

        get thread comments: this are the parent comments of the current selected comment (useCommentParents). this is to render what is this comment replying to.

        get thread author Ids

        get comment author contacts

        get the root comment Id (the first item in the thread comments)

        Render ONE comment group

      Web App

        the comment is being passed to the component

        get all comments

        get comment groups

        construct the comment thread

        get all author ids from thread and from commentGroups

        return thread, commentGroups and authors

        render ONE comment group and also the commentGroups below