From 94f2456fcffbc062bf42fa26b03e3d91406881cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Fri, 19 Sep 2025 14:00:49 -0300 Subject: [PATCH 1/6] DEV: Remove deprecated widget overrides and streamline `post` handling Remove deprecated `discourse.post-stream-widget-overrides` and associated legacy widget customizations. This cleanup reduces technical debt, ensures future maintainability, and aligns with the latest framework improvements. --- .../intitialize-whos-online-indicators.gjs | 58 ------------------- 1 file changed, 58 deletions(-) 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..d76c0fd 100644 --- a/assets/javascripts/discourse/api-initializers/intitialize-whos-online-indicators.gjs +++ b/assets/javascripts/discourse/api-initializers/intitialize-whos-online-indicators.gjs @@ -1,6 +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"; @@ -93,61 +92,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 []; - }, - }); } From 061c34feb8fd30869e25aca9b5f40b984192eee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Mon, 22 Sep 2025 21:59:10 -0300 Subject: [PATCH 2/6] DEV: Clean up unused `PLUGIN_ID` in `whos-online` initializer Remove the unused `PLUGIN_ID` constant in the `whos-online` API initializer to reduce redundant code. This aligns with code cleanliness and maintainability standards for the plugin. --- .../api-initializers/intitialize-whos-online-indicators.gjs | 2 -- 1 file changed, 2 deletions(-) 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 d76c0fd..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,6 @@ import bodyClass from "discourse/helpers/body-class"; import { apiInitializer } from "discourse/lib/api"; -const PLUGIN_ID = "whos-online"; - export default apiInitializer((api) => { const siteSettings = api.container.lookup("service:site-settings"); const whosOnlineService = api.container.lookup("service:whos-online"); From 37cbede2a99f47a098888bc5500257502d790a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Wed, 19 Nov 2025 15:53:25 -0300 Subject: [PATCH 3/6] DEV: Update `whos-online` plugin compatibility for new beta version Add compatibility entry for Discourse version `< 3.6.0.beta3-latest` in the `discourse-whos-online` plugin. This ensures accurate version constraints and prevents potential issues with unsupported Discourse versions. --- .discourse-compatibility | 1 + 1 file changed, 1 insertion(+) diff --git a/.discourse-compatibility b/.discourse-compatibility index 0fd246b..d705706 100644 --- a/.discourse-compatibility +++ b/.discourse-compatibility @@ -1,3 +1,4 @@ +< 3.6.0.beta3-latest: 3fe319b82c9146b15743537d38fdff753c35dfdb < 3.6.0.beta1-dev: 232ac13322c390ee7646007b91982e7617dccb90 < 3.5.0.beta8-dev: 76183351645aea8d0837f602d9f3ab8c89994ed6 < 3.5.0.beta5-dev: 7b5201ca936208a19e29c4a1d3b16511120c3fd3 From 65dbccc1911b0d3fad5717968bec4314d1be96bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Tue, 25 Nov 2025 18:03:44 -0300 Subject: [PATCH 4/6] DEV: Remove the legacy widget code --- .../discourse/services/whos-online.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/assets/javascripts/discourse/services/whos-online.js b/assets/javascripts/discourse/services/whos-online.js index de0400f..22e5c87 100755 --- a/assets/javascripts/discourse/services/whos-online.js +++ b/assets/javascripts/discourse/services/whos-online.js @@ -15,9 +15,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 +29,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; From b8b4ce3193a7914a070e9f990e876d401e116078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Wed, 26 Nov 2025 14:51:01 -0300 Subject: [PATCH 5/6] DEV: Update .discourse-compatibility Adjust the `.discourse-compatibility` file to reflect compatibility with `< 2025.12.0-latest`, ensuring the plugin aligns with upcoming core versioning changes. This update preempts potential mismatches and maintains plugin functionality with evolving Discourse core updates. --- .discourse-compatibility | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.discourse-compatibility b/.discourse-compatibility index 01895a1..72fcf3f 100644 --- a/.discourse-compatibility +++ b/.discourse-compatibility @@ -1,4 +1,4 @@ -< 3.6.0.beta3-latest: 3fe319b82c9146b15743537d38fdff753c35dfdb +< 2025.12.0-latest: 3fe319b82c9146b15743537d38fdff753c35dfdb < 3.6.0.beta2-latest: 68e88152d28189b3c22ec0011729fd765cf5c43a < 3.6.0.beta1-dev: 232ac13322c390ee7646007b91982e7617dccb90 < 3.5.0.beta8-dev: 76183351645aea8d0837f602d9f3ab8c89994ed6 From 81412dab3252b1753dde00cd9944654e841a666a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Wed, 26 Nov 2025 14:51:39 -0300 Subject: [PATCH 6/6] DEV: Remove unused `appEvents` service from `whos-online` Eliminate the unused `appEvents` service injection in `WhosOnlineService` to clean up the code and improve maintainability. This reduces unnecessary dependencies and aligns with recent refactoring efforts in the plugin. --- assets/javascripts/discourse/services/whos-online.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/javascripts/discourse/services/whos-online.js b/assets/javascripts/discourse/services/whos-online.js index 22e5c87..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;