Modernize CommentIssueManager for performance, bug fixes, usability.

Review Request #13712 — Created April 7, 2024 and submitted — Latest diff uploaded

Information

Review Board
release-7.x

Reviewers

CommentIssueManager was one of the earliest classes introduced when we
moved to Backbone. It had some usability flaws in terms of how its APIs
worked, and some performance flaws in its way of notifying callers of
issue status changes.

It also had a major caching bug where two comments of different types
but sharing the same ID would be seen as identical in the cache. This
could lead to issues setting and checking comment state. We had a bug
around this, and fixed a symptom around it, but did not identify this
cause beforehand.

This new version is ported to Spina and TypeScript and does the
following:

  • It avoids the caching bug by having a more specific cache key.

  • It includes new functions for accessing objects, which include
    options-based parameters instead of positional parameters to help with
    typing, readability, and extensibility. The old methods are
    deprecated.

  • Callers can now listen to comment-specific events, instead of having
    to listen for and check every single comment tracked in the manager.
    This is done via a new issueStatusUpdated:<type>:<id> event, which
    provides an object-based payload.

  • The old issueStatusUpdated still exists, but is also now replaced
    with a new anyIssueStatusUpdated with an object-based payload as
    well.

Some typing changes to BaseComment and Review have been updated to
make some arguments optional. These were technically optional, but not
typed that way. Since those impacted typing here, they're being changed
accordingly.

Unit tests pass.

Made use of some of this in an in-progress change.

Diff Revision 3 (Latest)

orig
1
2
3

Commits

First Last Summary ID Author
Modernize CommentIssueManager for performance, bug fixes, usability.
`CommentIssueManager` was one of the earliest classes introduced when we moved to Backbone. It had some usability flaws in terms of how its APIs worked, and some performance flaws in its way of notifying callers of issue status changes. It also had a major caching bug where two comments of different types but sharing the same ID would be seen as identical in the cache. This could lead to issues setting and checking comment state. We had a bug around this, and fixed a symptom around it, but did not identify this cause beforehand. This new version is ported to Spina and TypeScript and does the following: * It avoids the caching bug by having a more specific cache key. * It includes new functions for accessing objects, which include options-based parameters instead of positional parameters to help with typing, readability, and extensibility. The old methods are deprecated. * Callers can now listen to comment-specific events, instead of having to listen for and check every single comment tracked in the manager. This is done via a new `issueStatusUpdated:<type>:<id>` event, which provides an object-based payload. * The old `issueStatusUpdated` still exists, but is also now replaced with a new `anyIssueStatusUpdated` with an object-based payload as well. Some typing changes to `BaseComment` and `Review` have been updated to make some arguments optional. These were technically optional, but not typed that way. Since those impacted typing here, they're being changed accordingly.
574cc9d69fbea9d14191aec81780b05097a02d45 Christian Hammond
reviewboard/staticbundles.py
reviewboard/static/rb/js/common/resources/models/baseCommentModel.ts
reviewboard/static/rb/js/common/resources/models/reviewModel.ts
reviewboard/static/rb/js/models/commentIssueManagerModel.es6.js
reviewboard/static/rb/js/reviews/index.ts
reviewboard/static/rb/js/reviews/models/commentIssueManagerModel.ts
reviewboard/static/rb/js/reviews/models/tests/commentIssueManagerModelTests.ts
reviewboard/static/rb/js/reviews/models/tests/index.ts
Loading...