[REF] mail, im_livechat: move chat window notify to discuss folder
Part of task-3265211 Part-of: odoo/odoo#125388
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { ChatWindowService } from "@mail/core/common/chat_window_service";
|
||||
import { Composer } from "@mail/core/common/composer";
|
||||
import { Message as MessageModel } from "@mail/core/common/message_model";
|
||||
import { Store } from "@mail/core/common/store_service";
|
||||
@@ -9,12 +8,6 @@ import { ThreadService } from "@mail/core/common/thread_service";
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(ChatWindowService.prototype, "im_livechat/disabled", {
|
||||
notifyState() {
|
||||
return;
|
||||
},
|
||||
});
|
||||
|
||||
patch(Composer.prototype, "im_livechat/disabled", {
|
||||
get allowUpload() {
|
||||
return false;
|
||||
|
||||
@@ -106,12 +106,10 @@ export class ChatWindow extends Component {
|
||||
} else {
|
||||
this.chatWindowService.toggleFold(this.props.chatWindow);
|
||||
}
|
||||
this.chatWindowService.notifyState(this.props.chatWindow);
|
||||
}
|
||||
|
||||
close(options) {
|
||||
this.chatWindowService.close(this.props.chatWindow, options);
|
||||
this.chatWindowService.notifyState(this.props.chatWindow);
|
||||
}
|
||||
|
||||
get moreMenuText() {
|
||||
|
||||
@@ -24,6 +24,19 @@ export class ChatWindowService {
|
||||
this.ui = services.ui;
|
||||
}
|
||||
|
||||
open(thread, replaceNewMessageChatWindow) {
|
||||
const chatWindow = this.insert({
|
||||
folded: false,
|
||||
thread,
|
||||
replaceNewMessageChatWindow,
|
||||
});
|
||||
chatWindow.autofocus++;
|
||||
if (thread) {
|
||||
thread.state = "open";
|
||||
}
|
||||
return chatWindow;
|
||||
}
|
||||
|
||||
openNewMessage() {
|
||||
if (this.store.chatWindows.some(({ thread }) => !thread)) {
|
||||
// New message chat window is already opened.
|
||||
@@ -61,22 +74,6 @@ export class ChatWindowService {
|
||||
return maxAmountWithoutHidden;
|
||||
}
|
||||
|
||||
notifyState(chatWindow) {
|
||||
if (this.ui.isSmall) {
|
||||
return;
|
||||
}
|
||||
if (chatWindow.thread?.model === "discuss.channel") {
|
||||
return this.orm.silent.call(
|
||||
"discuss.channel",
|
||||
"channel_fold",
|
||||
[[chatWindow.thread.id]],
|
||||
{
|
||||
state: chatWindow.thread.state,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ChatWindowData} [data]
|
||||
* @returns {ChatWindow}
|
||||
@@ -147,7 +144,7 @@ export class ChatWindowService {
|
||||
chatWindow.thread.state = "folded";
|
||||
}
|
||||
|
||||
async close(chatWindow, { escape = false } = {}) {
|
||||
close(chatWindow, { escape = false } = {}) {
|
||||
if (this.maxVisible < this.store.chatWindows.length) {
|
||||
const swaped = this.hidden[0];
|
||||
swaped.hidden = false;
|
||||
|
||||
@@ -171,17 +171,7 @@ patch(ThreadService.prototype, "mail/core/web", {
|
||||
},
|
||||
open(thread, replaceNewMessageChatWindow) {
|
||||
if (!this.store.discuss.isActive || this.ui.isSmall) {
|
||||
const chatWindow = this.chatWindowService.insert({
|
||||
folded: false,
|
||||
thread,
|
||||
replaceNewMessageChatWindow,
|
||||
});
|
||||
chatWindow.autofocus++;
|
||||
if (thread) {
|
||||
thread.state = "open";
|
||||
}
|
||||
this.chatWindowService.notifyState(chatWindow);
|
||||
return;
|
||||
this.chatWindowService.open(thread, replaceNewMessageChatWindow);
|
||||
}
|
||||
this._super(thread, replaceNewMessageChatWindow);
|
||||
},
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { ChatWindowService } from "@mail/core/common/chat_window_service";
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(ChatWindowService.prototype, "discuss/core/web", {
|
||||
close(chatWindow) {
|
||||
this._super(...arguments);
|
||||
this.notifyState(chatWindow);
|
||||
},
|
||||
hide(chatWindow) {
|
||||
this._super(...arguments);
|
||||
this.notifyState(chatWindow);
|
||||
},
|
||||
notifyState(chatWindow) {
|
||||
if (this.ui.isSmall) {
|
||||
return;
|
||||
}
|
||||
if (chatWindow.thread?.model === "discuss.channel") {
|
||||
return this.orm.silent.call(
|
||||
"discuss.channel",
|
||||
"channel_fold",
|
||||
[[chatWindow.thread.id]],
|
||||
{
|
||||
state: chatWindow.thread.state,
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
open() {
|
||||
const chatWindow = this._super(...arguments);
|
||||
this.notifyState(chatWindow);
|
||||
},
|
||||
show(chatWindow) {
|
||||
this._super(...arguments);
|
||||
this.notifyState(chatWindow);
|
||||
},
|
||||
toggleFold(chatWindow) {
|
||||
this._super(...arguments);
|
||||
this.notifyState(chatWindow);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user