UX: Don't block render of user messages secondary nav for tracking state (#21965)

Why is this change required?

Right now, we're awaiting on the promise returned by
`this.pmTopicTrackingState.startTracking()` which blocks the rendering
of the template until the promise resolves. However, this blocking of
the rendering ends up introducing yet another intermediate loading state
in the UI which we find unsightly. Instead of blocking the rendering, we
allow the promise to resolve in the background and display the
new/unread counts when the promise resolves.
This commit is contained in:
Alan Guo Xiang Tan 2023-06-07 13:37:05 +09:00 committed by GitHub
parent fc296b9a81
commit 9a18c8032a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -11,7 +11,8 @@ export default class extends Controller {
@computed(
"pmTopicTrackingState.newIncoming.[]",
"pmTopicTrackingState.statesModificationCounter"
"pmTopicTrackingState.statesModificationCounter",
"pmTopicTrackingState.isTracking"
)
get newLinkText() {
return this.#linkText("new");
@ -19,7 +20,8 @@ export default class extends Controller {
@computed(
"pmTopicTrackingState.newIncoming.[]",
"pmTopicTrackingState.statesModificationCounter"
"pmTopicTrackingState.statesModificationCounter",
"pmTopicTrackingState.isTracking"
)
get unreadLinkText() {
return this.#linkText("unread");

View File

@ -22,7 +22,8 @@ export default class extends Controller {
@computed(
"pmTopicTrackingState.newIncoming.[]",
"pmTopicTrackingState.statesModificationCounter"
"pmTopicTrackingState.statesModificationCounter",
"pmTopicTrackingState.isTracking"
)
get newLinkText() {
return this.#linkText("new");
@ -30,7 +31,8 @@ export default class extends Controller {
@computed(
"pmTopicTrackingState.newIncoming.[]",
"pmTopicTrackingState.statesModificationCounter"
"pmTopicTrackingState.statesModificationCounter",
"pmTopicTrackingState.isTracking"
)
get unreadLinkText() {
return this.#linkText("unread");

View File

@ -8,12 +8,8 @@ export default DiscourseRoute.extend({
templateName: "user/messages",
composer: service(),
model() {
return this.modelFor("user");
},
afterModel() {
return this.pmTopicTrackingState.startTracking();
this.pmTopicTrackingState.startTracking();
},
setupController() {