Skip to content

Refactor initRepoIssueContentHistory to load histories dynamically #17916

Closed as not planned
@wxiaoguang

Description

@wxiaoguang

Background

Every call to initRepoIssueContentHistory loads all histories data. In many cases (eg: dynamic loading, edited content), we only need to load some histories.

Solution

I think it can be done mostly in frontend, then we do not need to change backend code (no more dependencies or coupling, no need to make template files more complex)

  1. initRepoIssueContentHistory() => attachRepoIssueContentHistory(targetCommentId=null)
  2. GET /content-history/overview => POST /content-history/overview with {commentIdList: [...] }, only query the overview information for commentIdList
  3. If targetCommentId==null, attachRepoIssueContentHistory would collect all history-menu-not-attached comment IDs, and send to backend to query overview.
  4. Then re-calling attachRepoIssueContentHistory(null) won't send redundant requests, we can call it safely at any time (Improvement)
  5. If a content is edited, we can call attachRepoIssueContentHistory(commentId) to do a refresh and show the history menu (Improvement)

Originally posted by @wxiaoguang in #17819 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/refactoringExisting code has been cleaned up. There should be no new functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions