A platform for community discussion. Free, open, simple.
FIX: offline mode should not send typing indicator (#35279)
Régis Hanol4364d1eaab67
diff --git a/plugins/discourse-presence/assets/javascripts/discourse/services/composer-presence-manager.js b/plugins/discourse-presence/assets/javascripts/discourse/services/composer-presence-manager.jsindex f45e39c385d..14f905dad63 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/services/composer-presence-manager.js+++ b/plugins/discourse-presence/assets/javascripts/discourse/services/composer-presence-manager.js@@ -7,7 +7,6 @@ const KEEP_ALIVE = 10 * 1000; // 10 secondsexport default class ComposerPresenceManager extends Service {@service currentUser;@service presence;- @service siteSettings;notifyState(name, replying = true, keepAlive = KEEP_ALIVE) {if (!replying) {@@ -15,10 +14,7 @@ export default class ComposerPresenceManager extends Service {return;}- const canHideProfile = this.siteSettings.allow_users_to_hide_profile;- const isHidingPresence = this.currentUser.user_option.hide_presence;-- if (canHideProfile && isHidingPresence) {+ if (this.currentUser.user_option.hide_presence) {return;}diff --git a/plugins/discourse-presence/test/javascripts/acceptance/discourse-presence-test.js b/plugins/discourse-presence/test/javascripts/acceptance/discourse-presence-test.jsindex f6191e19c38..d552efca757 100644--- a/plugins/discourse-presence/test/javascripts/acceptance/discourse-presence-test.js+++ b/plugins/discourse-presence/test/javascripts/acceptance/discourse-presence-test.js@@ -1,3 +1,4 @@+import { getOwner } from "@ember/owner";import { click, currentURL, fillIn, visit } from "@ember/test-helpers";import { test } from "qunit";import User from "discourse/models/user";@@ -66,6 +67,32 @@ acceptance("Discourse Presence Plugin", function (needs) {);});+ test("It respects the hide_presence user's preference, even when hiding profile is disabled", async function (assert) {+ const siteSettings = getOwner(this).lookup("service:site-settings");+ siteSettings.allow_users_to_hide_profile = false;++ User.current().set("user_option.hide_presence", true);++ await visit("/t/internationalization-localization/280");++ await click("#topic-footer-buttons .btn.create");+ assert.dom(".d-editor-input").exists("the composer input is visible");++ assert.deepEqual(+ presentUserIds("/discourse-presence/reply/280"),+ [],+ "does not publish presence for open composer"+ );++ await fillIn(".d-editor-input", "this is the content of my reply");++ assert.deepEqual(+ presentUserIds("/discourse-presence/reply/280"),+ [],+ "does not publish presence when typing"+ );+ });+test("Uses whisper channel for whispers", async function (assert) {await visit("/t/internationalization-localization/280");