This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6

28 lines
775 B
JavaScript

import Component from "@ember/component";
import { gt } from "@ember/object/computed";
import { inject as service } from "@ember/service";
import discourseComputed, { on } from "discourse-common/utils/decorators";
import { TOPIC_TYPE } from "discourse/plugins/discourse-presence/discourse/lib/presence";
export default Component.extend({
topic: null,
presenceManager: service(),
@discourseComputed("topic.id")
users(topicId) {
return this.presenceManager.users(topicId);
},
shouldDisplay: gt("users.length", 0),
@on("didInsertElement")
subscribe() {
this.presenceManager.subscribe(this.get("topic.id"), TOPIC_TYPE);
},
@on("willDestroyElement")
_destroyed() {
this.presenceManager.unsubscribe(this.get("topic.id"), TOPIC_TYPE);
}
});