mirror of
https://ghfast.top/https://github.com/discourse/discourse-follow.git
synced 2026-07-15 11:36:38 +08:00
Follow-up to discourse/discourse commit that simplified the method
signature from `addSaveableCustomFields({ page })` to
`addSaveableCustomFields(page)`.
cf. https://github.com/discourse/discourse/pull/36757
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
import { userPath } from "discourse/lib/url";
|
|
import { i18n } from "discourse-i18n";
|
|
|
|
export default {
|
|
name: "follow-plugin-initializer",
|
|
initialize(/*container*/) {
|
|
withPluginApi((api) => {
|
|
const currentUser = api.getCurrentUser();
|
|
if (!currentUser) {
|
|
return;
|
|
}
|
|
api.replaceIcon(
|
|
"notification.following",
|
|
"discourse-follow-new-follower"
|
|
);
|
|
api.replaceIcon(
|
|
"notification.following_created_topic",
|
|
"discourse-follow-new-topic"
|
|
);
|
|
api.replaceIcon(
|
|
"notification.following_replied",
|
|
"discourse-follow-new-reply"
|
|
);
|
|
|
|
if (api.registerNotificationTypeRenderer) {
|
|
api.registerNotificationTypeRenderer(
|
|
"following",
|
|
(NotificationTypeBase) => {
|
|
return class extends NotificationTypeBase {
|
|
get linkTitle() {
|
|
return i18n("notifications.titles.following");
|
|
}
|
|
|
|
get linkHref() {
|
|
return userPath(this.notification.data.display_username);
|
|
}
|
|
|
|
get icon() {
|
|
return "discourse-follow-new-follower";
|
|
}
|
|
|
|
get label() {
|
|
return this.notification.data.display_username;
|
|
}
|
|
|
|
get description() {
|
|
return i18n("notifications.following_description", {});
|
|
}
|
|
};
|
|
}
|
|
);
|
|
}
|
|
|
|
api.addSaveableCustomFields("notifications");
|
|
});
|
|
},
|
|
};
|