mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 13:39:36 -06:00
DEV: Change setActiveChannel to get/set in services/chat (#20237)
Per PR comment in #20209, we don't need to do setActiveChannel, we can just use native get/set instead.
This commit is contained in:
parent
cbd021db15
commit
c9776fe84d
@ -220,7 +220,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
openURL(URL = null) {
|
openURL(URL = null) {
|
||||||
this.chat.setActiveChannel(null);
|
this.chat.activeChannel = null;
|
||||||
this.chatStateManager.didOpenDrawer(URL);
|
this.chatStateManager.didOpenDrawer(URL);
|
||||||
|
|
||||||
const route = this._buildRouteFromURL(
|
const route = this._buildRouteFromURL(
|
||||||
@ -264,7 +264,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
_openChannel(channelId, afterRenderFunc = null) {
|
_openChannel(channelId, afterRenderFunc = null) {
|
||||||
return this.chatChannelsManager.find(channelId).then((channel) => {
|
return this.chatChannelsManager.find(channelId).then((channel) => {
|
||||||
this.chat.setActiveChannel(channel);
|
this.chat.activeChannel = channel;
|
||||||
this.set("view", CHAT_VIEW);
|
this.set("view", CHAT_VIEW);
|
||||||
this.appEvents.trigger("chat:float-toggled", false);
|
this.appEvents.trigger("chat:float-toggled", false);
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ export default Component.extend({
|
|||||||
openInFullPage() {
|
openInFullPage() {
|
||||||
this.chatStateManager.storeAppURL();
|
this.chatStateManager.storeAppURL();
|
||||||
this.chatStateManager.prefersFullPage();
|
this.chatStateManager.prefersFullPage();
|
||||||
this.chat.setActiveChannel(null);
|
this.chat.activeChannel = null;
|
||||||
|
|
||||||
return this.router.transitionTo(this.chatStateManager.lastKnownChatURL);
|
return this.router.transitionTo(this.chatStateManager.lastKnownChatURL);
|
||||||
},
|
},
|
||||||
@ -297,7 +297,7 @@ export default Component.extend({
|
|||||||
close() {
|
close() {
|
||||||
this.computeDrawerStyle();
|
this.computeDrawerStyle();
|
||||||
this.chatStateManager.didCloseDrawer();
|
this.chatStateManager.didCloseDrawer();
|
||||||
this.chat.setActiveChannel(null);
|
this.chat.activeChannel = null;
|
||||||
this.appEvents.trigger("chat:float-toggled", true);
|
this.appEvents.trigger("chat:float-toggled", true);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ export default Component.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chat.setActiveChannel(channel);
|
this.chat.activeChannel = channel;
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
const URL = this._buildURLFromState(LIST_VIEW);
|
const URL = this._buildURLFromState(LIST_VIEW);
|
||||||
|
@ -5,7 +5,7 @@ export default class ChatBrowseIndexRoute extends DiscourseRoute {
|
|||||||
@service chat;
|
@service chat;
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this.chat.setActiveChannel(null);
|
this.chat.activeChannel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
afterModel() {
|
afterModel() {
|
||||||
|
@ -12,7 +12,7 @@ export default function withChatChannel(extendedClass) {
|
|||||||
|
|
||||||
afterModel(model) {
|
afterModel(model) {
|
||||||
this.controllerFor("chat-channel").set("targetMessageId", null);
|
this.controllerFor("chat-channel").set("targetMessageId", null);
|
||||||
this.chat.setActiveChannel(model);
|
this.chat.activeChannel = model;
|
||||||
|
|
||||||
let { messageId } = this.paramsFor(this.routeName);
|
let { messageId } = this.paramsFor(this.routeName);
|
||||||
// messageId query param backwards-compatibility
|
// messageId query param backwards-compatibility
|
||||||
|
@ -11,6 +11,6 @@ export default class ChatDraftChannelRoute extends DiscourseRoute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this.chat.setActiveChannel(null);
|
this.chat.activeChannel = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ export default class ChatRoute extends DiscourseRoute {
|
|||||||
@action
|
@action
|
||||||
willTransition(transition) {
|
willTransition(transition) {
|
||||||
if (!transition?.to?.name?.startsWith("chat.channel")) {
|
if (!transition?.to?.name?.startsWith("chat.channel")) {
|
||||||
this.chat.setActiveChannel(null);
|
this.chat.activeChannel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!transition?.to?.name?.startsWith("chat.")) {
|
if (!transition?.to?.name?.startsWith("chat.")) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
import { tracked } from "@glimmer/tracking";
|
||||||
import userSearch from "discourse/lib/user-search";
|
import userSearch from "discourse/lib/user-search";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import Service, { inject as service } from "@ember/service";
|
import Service, { inject as service } from "@ember/service";
|
||||||
@ -35,7 +36,8 @@ export default class Chat extends Service {
|
|||||||
@service site;
|
@service site;
|
||||||
@service chatChannelsManager;
|
@service chatChannelsManager;
|
||||||
|
|
||||||
activeChannel = null;
|
@tracked activeChannel = null;
|
||||||
|
|
||||||
cook = null;
|
cook = null;
|
||||||
presenceChannel = null;
|
presenceChannel = null;
|
||||||
sidebarActive = false;
|
sidebarActive = false;
|
||||||
@ -116,10 +118,6 @@ export default class Chat extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setActiveChannel(channel) {
|
|
||||||
this.set("activeChannel", channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
loadCookFunction(categories) {
|
loadCookFunction(categories) {
|
||||||
if (this.cook) {
|
if (this.cook) {
|
||||||
return Promise.resolve(this.cook);
|
return Promise.resolve(this.cook);
|
||||||
@ -281,12 +279,12 @@ export default class Chat extends Service {
|
|||||||
this.router.currentRouteName === "chat.channel.near-message") &&
|
this.router.currentRouteName === "chat.channel.near-message") &&
|
||||||
this.activeChannel?.id === channel.id
|
this.activeChannel?.id === channel.id
|
||||||
) {
|
) {
|
||||||
this.setActiveChannel(channel);
|
this.activeChannel = channel;
|
||||||
this._fireOpenMessageAppEvent(messageId);
|
this._fireOpenMessageAppEvent(messageId);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setActiveChannel(channel);
|
this.activeChannel = channel;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.chatStateManager.isFullPageActive ||
|
this.chatStateManager.isFullPageActive ||
|
||||||
|
Loading…
Reference in New Issue
Block a user