Skip to content

Commit

Permalink
DEV: Prevent Ember computation error when subscribing (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
megothss authored Jan 23, 2025
1 parent 88df6c1 commit bcb5092
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { service } from "@ember/service";
import { apiInitializer } from "discourse/lib/api";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import discourseComputed, { observes } from "discourse/lib/decorators";

const PLUGIN_ID = "whos-online";

export default apiInitializer("1.39.0", (api) => {
const siteSettings = api.container.lookup("service:site-settings");

// pre-initialize the service so that it can start listening to the presence channel
// and avoid triggering "... was previously used in the same computation" errors
// while subscribing
api.container.lookup("service:whos-online");

const indicatorType = siteSettings.whos_online_avatar_indicator;
if (indicatorType === "none") {
return;
Expand Down Expand Up @@ -74,7 +79,6 @@ export default apiInitializer("1.39.0", (api) => {
context: { topic },
}) => {
const whosOnline = api.container.lookup("service:whos-online");

const lastPosterId = topic.lastPoster.id;
const lastPosterUserId = topic.lastPosterUser.id;

Expand Down

0 comments on commit bcb5092

Please sign in to comment.