diff --git a/.discourse-compatibility b/.discourse-compatibility index 0fd246b..0867765 100644 --- a/.discourse-compatibility +++ b/.discourse-compatibility @@ -1,3 +1,4 @@ +< 3.6.0.beta2-latest: 68e88152d28189b3c22ec0011729fd765cf5c43a < 3.6.0.beta1-dev: 232ac13322c390ee7646007b91982e7617dccb90 < 3.5.0.beta8-dev: 76183351645aea8d0837f602d9f3ab8c89994ed6 < 3.5.0.beta5-dev: 7b5201ca936208a19e29c4a1d3b16511120c3fd3 diff --git a/assets/javascripts/discourse/components/whos-online-avatar.gjs b/assets/javascripts/discourse/components/whos-online-avatar.gjs index 9a160f3..f0ebf51 100644 --- a/assets/javascripts/discourse/components/whos-online-avatar.gjs +++ b/assets/javascripts/discourse/components/whos-online-avatar.gjs @@ -1,16 +1,14 @@ -import Component from "@ember/component"; import avatar from "discourse/helpers/avatar"; -export default class WhosOnlineAvatar extends Component { - tagName = "a"; - attributeBindings = ["user.username:data-user-card", "user.path:href"]; - - ; + +export default WhosOnlineAvatar; diff --git a/assets/javascripts/discourse/components/whos-online.gjs b/assets/javascripts/discourse/components/whos-online.gjs index b2b0e84..bd5f747 100644 --- a/assets/javascripts/discourse/components/whos-online.gjs +++ b/assets/javascripts/discourse/components/whos-online.gjs @@ -1,6 +1,4 @@ import Component from "@ember/component"; -import { computed } from "@ember/object"; -import { readOnly } from "@ember/object/computed"; import { service } from "@ember/service"; import { i18n } from "discourse-i18n"; import WhosOnlineAvatar from "./whos-online-avatar"; @@ -8,9 +6,6 @@ import WhosOnlineAvatar from "./whos-online-avatar"; export default class WhosOnline extends Component { @service whosOnline; - @readOnly("whosOnline.count") count; - - @computed("whosOnline.users.[]") get users() { return this.whosOnline.users?.slice( 0, @@ -18,22 +13,22 @@ export default class WhosOnline extends Component { ); } - @computed("users", "users.length") get hasUsers() { return this.users?.length >= this.siteSettings.whos_online_minimum_display; } - @computed("count") + get count() { + return this.whosOnline.count; + } + get hasCount() { return this.count >= this.siteSettings.whos_online_minimum_display; } - @computed("count") get isLong() { return this.count >= this.siteSettings.whos_online_collapse_threshold; } - @computed("count") get shouldDisplay() { if ( this.count < this.siteSettings.whos_online_minimum_display && diff --git a/assets/javascripts/discourse/services/whos-online.js b/assets/javascripts/discourse/services/whos-online.js index 432fc6a..de0400f 100755 --- a/assets/javascripts/discourse/services/whos-online.js +++ b/assets/javascripts/discourse/services/whos-online.js @@ -1,5 +1,3 @@ -import { computed } from "@ember/object"; -import { readOnly } from "@ember/object/computed"; import Service, { service } from "@ember/service"; import Site from "discourse/models/site"; @@ -7,22 +5,34 @@ export default class WhosOnlineService extends Service { @service presence; @service appEvents; - @readOnly("channel.users") users; - @readOnly("channel.count") count; - @readOnly("channel.countOnly") countOnly; + #channel; init() { super.init(...arguments); - this.set("channel", this.presence.getChannel("/whos-online/online")); + this.#channel = this.presence.getChannel("/whos-online/online"); if (this.enabled) { - this.channel.subscribe(Site.currentProp("whos_online_state")); + this.#channel.subscribe(Site.currentProp("whos_online_state")); } + // TODO (glimmer-post-stream): remove this observer when removing the legacy widget code this.addObserver("users.[]", this, this._usersChanged); } + get users() { + return this.#channel?.users; + } + + get count() { + return this.#channel?.count || 0; + } + + get countOnly() { + return this.#channel?.countOnly || 0; + } + + // TODO (glimmer-post-stream): remove this function when removing the legacy widget code _usersChanged() { const currentUserIds = new Set(this.users?.map((u) => u.id) || []); const prevUserIds = this._prevUserIds || new Set([]); @@ -36,7 +46,6 @@ export default class WhosOnlineService extends Service { } } - @computed get enabled() { const anonAndLoginRequired = !this.currentUser && this.siteSettings.login_required; @@ -52,6 +61,6 @@ export default class WhosOnlineService extends Service { } isUserOnline(id) { - return !!this.channel?.users?.find((user) => user.id === id); + return !!this.#channel?.users?.find((user) => user.id === id); } }