mirror of
https://github.com/discourse/discourse.git
synced 2025-02-11 18:54:16 +08:00
43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||
|
import PresenceManager from "../discourse/lib/presence-manager";
|
||
|
|
||
|
function initializeDiscoursePresence(api) {
|
||
|
const currentUser = api.getCurrentUser();
|
||
|
const siteSettings = api.container.lookup("site-settings:main");
|
||
|
|
||
|
if (currentUser && !currentUser.hide_profile_and_presence) {
|
||
|
api.modifyClass("model:topic", {
|
||
|
presenceManager: null
|
||
|
});
|
||
|
|
||
|
api.modifyClass("route:topic-from-params", {
|
||
|
setupController() {
|
||
|
this._super(...arguments);
|
||
|
|
||
|
this.modelFor("topic").set(
|
||
|
"presenceManager",
|
||
|
PresenceManager.create({
|
||
|
topic: this.modelFor("topic"),
|
||
|
currentUser,
|
||
|
messageBus: api.container.lookup("message-bus:main"),
|
||
|
siteSettings
|
||
|
})
|
||
|
);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default {
|
||
|
name: "discourse-presence",
|
||
|
after: "message-bus",
|
||
|
|
||
|
initialize(container) {
|
||
|
const siteSettings = container.lookup("site-settings:main");
|
||
|
|
||
|
if (siteSettings.presence_enabled) {
|
||
|
withPluginApi("0.8.40", initializeDiscoursePresence);
|
||
|
}
|
||
|
}
|
||
|
};
|