diff --git a/.discourse-compatibility b/.discourse-compatibility index 0867765..72fcf3f 100644 --- a/.discourse-compatibility +++ b/.discourse-compatibility @@ -1,3 +1,4 @@ +< 2025.12.0-latest: 3fe319b82c9146b15743537d38fdff753c35dfdb < 3.6.0.beta2-latest: 68e88152d28189b3c22ec0011729fd765cf5c43a < 3.6.0.beta1-dev: 232ac13322c390ee7646007b91982e7617dccb90 < 3.5.0.beta8-dev: 76183351645aea8d0837f602d9f3ab8c89994ed6 diff --git a/assets/javascripts/discourse/api-initializers/intitialize-whos-online-indicators.gjs b/assets/javascripts/discourse/api-initializers/intitialize-whos-online-indicators.gjs index 7a05c4e..57a712a 100644 --- a/assets/javascripts/discourse/api-initializers/intitialize-whos-online-indicators.gjs +++ b/assets/javascripts/discourse/api-initializers/intitialize-whos-online-indicators.gjs @@ -1,8 +1,5 @@ import bodyClass from "discourse/helpers/body-class"; import { apiInitializer } from "discourse/lib/api"; -import { withSilencedDeprecations } from "discourse/lib/deprecated"; - -const PLUGIN_ID = "whos-online"; export default apiInitializer((api) => { const siteSettings = api.container.lookup("service:site-settings"); @@ -93,61 +90,4 @@ function customizePost(api) { return value; } ); - - withSilencedDeprecations("discourse.post-stream-widget-overrides", () => - customizeWidgetPost(api) - ); -} - -function customizeWidgetPost(api) { - api.modifyClass("component:scrolling-post-stream", { - pluginId: PLUGIN_ID, - - didInsertElement() { - this._super(); - this.appEvents.on("whosonline:changed", this, this._whosOnlineCallback); - }, - - willDestroyElement() { - this.appEvents.off("whosonline:changed", this, this._whosOnlineCallback); - }, - - _whosOnlineCallback(changedUserIds) { - changedUserIds.forEach((id) => { - let postIds = this.attrs.posts.value - .filter(({ user_id }) => { - return user_id === id; - }) - .map((post) => post.id); - postIds.forEach((postId) => { - this.dirtyKeys.keyDirty(`post-${postId}`); - this.dirtyKeys.keyDirty(`post-${postId}-avatar-${id}`, { - onRefresh: "updateOnline", - }); - }); - }); - this.queueRerender(); - }, - }); - - api.reopenWidget("post-avatar", { - buildKey: (attrs) => `post-${attrs.id}-avatar-${attrs.user_id}`, - isUserOnline(userId) { - return this.register.lookup("service:whos-online").isUserOnline(userId); - }, - defaultState(attrs) { - return { - online: this.isUserOnline(attrs.user_id), - }; - }, - updateOnline() { - this.state.online = this.isUserOnline(this.attrs.user_id); - }, - buildClasses(attrs, state) { - if (state.online) { - return "user-online"; - } - return []; - }, - }); } diff --git a/assets/javascripts/discourse/services/whos-online.js b/assets/javascripts/discourse/services/whos-online.js index de0400f..03bd266 100755 --- a/assets/javascripts/discourse/services/whos-online.js +++ b/assets/javascripts/discourse/services/whos-online.js @@ -3,7 +3,6 @@ import Site from "discourse/models/site"; export default class WhosOnlineService extends Service { @service presence; - @service appEvents; #channel; @@ -15,9 +14,6 @@ export default class WhosOnlineService extends Service { if (this.enabled) { 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() { @@ -32,20 +28,6 @@ export default class WhosOnlineService extends Service { 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([]); - - const enteredUsers = [...currentUserIds].filter((x) => !prevUserIds.has(x)); - const leftUsers = [...prevUserIds].filter((x) => !currentUserIds.has(x)); - const changedUsers = [...enteredUsers, ...leftUsers]; - - if (changedUsers.length > 0) { - this.appEvents.trigger("whosonline:changed", changedUsers); - } - } - get enabled() { const anonAndLoginRequired = !this.currentUser && this.siteSettings.login_required;