Skip to content

A platform for community discussion. Free, open, simple.

DEV: Warn when trying to track user status for user models without ID (#21205)

Andrei Prigorshnev9932f144c294
diff --git a/app/assets/javascripts/discourse/app/models/user.js b/app/assets/javascripts/discourse/app/models/user.js
index db53e68c53d..d225239173e 100644
--- a/app/assets/javascripts/discourse/app/models/user.js
+++ b/app/assets/javascripts/discourse/app/models/user.js
@@ -1401,6 +1401,13 @@ User.reopen(Evented, {
// always call stopTrackingStatus() when done with a user
trackStatus() {
+ if (!this.id) {
+ // eslint-disable-next-line no-console
+ console.warn(
+ "It's impossible to track user status on a user model that doesn't have id. This user model won't be receiving live user status updates."
+ );
+ }
+
if (this._subscribersCount === 0) {
this.addObserver("status", this, "_statusChanged");