Skip to content

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

PERF: Skip extraneous requests in full app embed mode (#39295)

Rafael dos Santos Silvaffe4ff8d7f70
diff --git a/frontend/discourse/app/instance-initializers/subscribe-user-notifications.js b/frontend/discourse/app/instance-initializers/subscribe-user-notifications.js
index 795e955c82d..b15afd57ee0 100644
--- a/frontend/discourse/app/instance-initializers/subscribe-user-notifications.js
+++ b/frontend/discourse/app/instance-initializers/subscribe-user-notifications.js
@@ -8,6 +8,7 @@ import {
init as initDesktopNotifications,
onNotification as onDesktopNotification,
} from "discourse/lib/desktop-notifications";
+import EmbedMode from "discourse/lib/embed-mode";
import { isTesting } from "discourse/lib/environment";
import {
isPushNotificationsEnabled,
@@ -69,7 +70,9 @@ class SubscribeUserNotificationsInit {
this.messageBus.subscribe("/client_settings", this.onClientSettings);
- this.pmTopicTrackingState.startTracking();
+ if (!EmbedMode.enabled) {
+ this.pmTopicTrackingState.startTracking();
+ }
if (!isTesting()) {
this.messageBus.subscribe(alertChannel(this.currentUser), this.onAlert);
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js
index 89198297dcf..9eb385e6468 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-setup.js
@@ -2,6 +2,7 @@ import { setOwner } from "@ember/owner";
import { service } from "@ember/service";
import EmojiPickerDetached from "discourse/components/emoji-picker/detached";
import { bind } from "discourse/lib/decorators";
+import EmbedMode from "discourse/lib/embed-mode";
import { number } from "discourse/lib/formatter";
import { replaceIcon } from "discourse/lib/icon-library";
import { withPluginApi } from "discourse/lib/plugin-api";
@@ -142,7 +143,7 @@ class ChatSetupInit {
});
});
- if (!this.chatService.userCanChat) {
+ if (!this.chatService.userCanChat || EmbedMode.enabled) {
return;
}
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat.js b/plugins/chat/assets/javascripts/discourse/services/chat.js
index a461b41798b..214addfc1cf 100644
--- a/plugins/chat/assets/javascripts/discourse/services/chat.js
+++ b/plugins/chat/assets/javascripts/discourse/services/chat.js
@@ -7,6 +7,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
import { uniqueItemsFromArray } from "discourse/lib/array-tools";
import { bind } from "discourse/lib/decorators";
import deprecated from "discourse/lib/deprecated";
+import EmbedMode from "discourse/lib/embed-mode";
import discourseLater from "discourse/lib/later";
import {
onPresenceChange,
@@ -40,7 +41,7 @@ export default class Chat extends Service {
init() {
super.init(...arguments);
- if (this.userCanChat) {
+ if (this.userCanChat && !EmbedMode.enabled) {
this.presenceChannel = this.presence.getChannel("/chat/online");
onPresenceChange({
@@ -54,7 +55,7 @@ export default class Chat extends Service {
willDestroy() {
super.willDestroy(...arguments);
- if (this.userCanChat) {
+ if (this.userCanChat && !EmbedMode.enabled) {
this.chatSubscriptionsManager.stopChannelsSubscriptions();
removeOnPresenceChange(this.onPresenceChangeCallback);
}
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-trigger.gjs b/plugins/discourse-ai/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-trigger.gjs
index f4816ba68a5..af1dfb58d19 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-trigger.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/connectors/topic-map-expanded-after/ai-summary-trigger.gjs
@@ -7,6 +7,7 @@ import { service } from "@ember/service";
import { trustHTML } from "@ember/template";
import { modifier } from "ember-modifier";
import DButton from "discourse/components/d-button";
+import EmbedMode from "discourse/lib/embed-mode";
import AiSummaryModal from "../../components/modal/ai-summary-modal";
export default class AiSummaryTrigger extends Component {
@@ -59,7 +60,7 @@ export default class AiSummaryTrigger extends Component {
this.creditStatus = null;
this.creditCheckComplete = false;
- if (!this.currentUser) {
+ if (!this.currentUser || EmbedMode.enabled) {
this.creditCheckComplete = true;
return;
}