mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 11:32:11 +08:00
DEV: Deprecate show_in_ui
argument of the register_stat
API (#28727)
We need to start printing deprecation notices when the `show_in_ui` argument is used because it works only for the old about page which will be removed soon. For the new about page, we've introduced a new API `addAboutPageActivity` which is more flexible than a true/false argument on the server side. Internal topic: t/136551.
This commit is contained in:
@ -29,11 +29,26 @@ class ChatSetupInit {
|
||||
setOwner(this, owner);
|
||||
this.appEvents.on("discourse:focus-changed", this, "_handleFocusChanged");
|
||||
|
||||
if (!this.chatService.userCanChat) {
|
||||
return;
|
||||
}
|
||||
|
||||
withPluginApi("0.12.1", (api) => {
|
||||
api.addAboutPageActivity("chat_messages", (periods) => {
|
||||
const count = periods["7_days"];
|
||||
if (count) {
|
||||
return {
|
||||
icon: "comment-dots",
|
||||
class: "chat-messages",
|
||||
activityText: I18n.t("about.activities.chat_messages", {
|
||||
count,
|
||||
formatted_number: number(count),
|
||||
}),
|
||||
period: I18n.t("about.activities.periods.last_7_days"),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.chatService.userCanChat) {
|
||||
return;
|
||||
}
|
||||
|
||||
api.onPageChange((path) => {
|
||||
const route = this.router.recognize(path);
|
||||
if (route.name.startsWith("chat.")) {
|
||||
@ -157,21 +172,6 @@ class ChatSetupInit {
|
||||
category: "organisms",
|
||||
id: "chat",
|
||||
});
|
||||
|
||||
api.addAboutPageActivity("chat_messages", (periods) => {
|
||||
const count = periods["7_days"];
|
||||
if (count) {
|
||||
return {
|
||||
icon: "comment-dots",
|
||||
class: "chat-messages",
|
||||
activityText: I18n.t("about.activities.chat_messages", {
|
||||
count,
|
||||
formatted_number: number(count),
|
||||
}),
|
||||
period: I18n.t("about.activities.periods.last_7_days"),
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -500,9 +500,7 @@ after_initialize do
|
||||
|
||||
register_email_unsubscriber("chat_summary", EmailControllerHelper::ChatSummaryUnsubscriber)
|
||||
|
||||
register_stat("chat_messages", show_in_ui: true, expose_via_api: true) do
|
||||
Chat::Statistics.about_messages
|
||||
end
|
||||
register_stat("chat_messages", expose_via_api: true) { Chat::Statistics.about_messages }
|
||||
register_stat("chat_users", expose_via_api: true) { Chat::Statistics.about_users }
|
||||
register_stat("chat_channels", expose_via_api: true) { Chat::Statistics.about_channels }
|
||||
|
||||
|
Reference in New Issue
Block a user