PERF: Remove request for PM topic tracking state initiated from sidebar (#20554)

What is the problem?

When constructing the "Messages" section in Sidebar, we call
startTracking() on the pm-topic-tracking-state service in order to
get the counts for new/unread for the private message inboxes for each
user. However, this is unnecessary because the inboxes are in a
collapsed state by default in the sidebar and are only expanded when the
current route correspond to the inbox's route. Therefore, we can avoid
calling startTracking() on the pm-topic-tracking-state service until
an inbox's route is loaded. This allows us to cut out one extra request
to the server on page load and defer it until it is necessarily.
This commit is contained in:
Alan Guo Xiang Tan 2023-03-08 07:07:23 +08:00 committed by GitHub
parent 2781264711
commit 5e0c95ed83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 12 deletions

View File

@ -38,10 +38,6 @@ export default class SidebarUserMessagesSection extends Component {
this._refreshSectionLinksDisplayState
);
this.pmTopicTrackingState
.startTracking()
.then(this._refreshSectionLinkCounts);
this._pmTopicTrackingStateKey = "messages-section";
this.pmTopicTrackingState.onStateChange(

View File

@ -376,6 +376,10 @@ acceptance(
"service:pm-topic-tracking-state"
);
await click(
".sidebar-section-messages .sidebar-section-link-group-messages-inbox.group1"
);
await publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
topic_id: 1,
message_type: "unread",
@ -398,10 +402,6 @@ acceptance(
},
});
await click(
".sidebar-section-messages .sidebar-section-link-group-messages-inbox.group1"
);
assert.strictEqual(
query(
".sidebar-section-messages .sidebar-section-link-group-messages-unread.group1"
@ -449,6 +449,10 @@ acceptance(
"service:pm-topic-tracking-state"
);
await click(
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox"
);
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
topic_id: 1,
message_type: "unread",
@ -460,10 +464,6 @@ acceptance(
},
});
await click(
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox"
);
assert.strictEqual(
query(
".sidebar-section-messages .sidebar-section-link-personal-messages-unread"