mirror of
https://github.com/discourse/discourse.git
synced 2025-04-08 21:10:48 +08:00
PR reviews
This commit is contained in:
parent
f71e3c07dd
commit
1ee9356a54
@ -2,9 +2,9 @@ import { inject as service } from "@ember/service";
|
|||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { cached } from "@glimmer/tracking";
|
import { cached } from "@glimmer/tracking";
|
||||||
|
|
||||||
|
import { debounce } from "discourse-common/utils/decorators";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import SidebarCommonCategoriesSection from "discourse/components/sidebar/common/categories-section";
|
import SidebarCommonCategoriesSection from "discourse/components/sidebar/common/categories-section";
|
||||||
import discourseDebounce from "discourse-common/lib/debounce";
|
|
||||||
|
|
||||||
export const REFRESH_COUNTS_APP_EVENT_NAME =
|
export const REFRESH_COUNTS_APP_EVENT_NAME =
|
||||||
"sidebar:refresh-categories-section-counts";
|
"sidebar:refresh-categories-section-counts";
|
||||||
@ -18,10 +18,10 @@ export default class SidebarUserCategoriesSection extends SidebarCommonCategorie
|
|||||||
super(...arguments);
|
super(...arguments);
|
||||||
|
|
||||||
this.callbackId = this.topicTrackingState.onStateChange(() => {
|
this.callbackId = this.topicTrackingState.onStateChange(() => {
|
||||||
this.#refreshCounts();
|
this._refreshCounts();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.appEvents.on(REFRESH_COUNTS_APP_EVENT_NAME, this, this.#refreshCounts);
|
this.appEvents.on(REFRESH_COUNTS_APP_EVENT_NAME, this, this._refreshCounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
willDestroy() {
|
willDestroy() {
|
||||||
@ -32,22 +32,17 @@ export default class SidebarUserCategoriesSection extends SidebarCommonCategorie
|
|||||||
this.appEvents.off(
|
this.appEvents.off(
|
||||||
REFRESH_COUNTS_APP_EVENT_NAME,
|
REFRESH_COUNTS_APP_EVENT_NAME,
|
||||||
this,
|
this,
|
||||||
this.#refreshCounts
|
this._refreshCounts
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#refreshCounts() {
|
|
||||||
// TopicTrackingState changes or plugins can trigger this function so we debounce to ensure we're not refreshing
|
// TopicTrackingState changes or plugins can trigger this function so we debounce to ensure we're not refreshing
|
||||||
// unnecessarily.
|
// unnecessarily.
|
||||||
discourseDebounce(
|
@debounce(300)
|
||||||
this,
|
_refreshCounts() {
|
||||||
() => {
|
|
||||||
this.sectionLinks.forEach((sectionLink) => {
|
this.sectionLinks.forEach((sectionLink) => {
|
||||||
sectionLink.refreshCounts();
|
sectionLink.refreshCounts();
|
||||||
});
|
});
|
||||||
},
|
|
||||||
300
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
|
Loading…
x
Reference in New Issue
Block a user