[FIX] mail: jumping on a message should not work outside the message thread
Before this PR, jumping on a message that is not displayed in it's originThread would not work. To reproduce: * star a message that is a reply. * open the starred menu. * Try to jump on the replied message. This PR fix the issue by not allowing the jump. closes odoo/odoo#132924 X-original-commit: 914f899f119e4b5f6271613b4af653211a32f915 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
committed by
Alexandre Kühn
parent
9849161a7d
commit
fdea4ee0e0
@@ -18,7 +18,7 @@
|
||||
<img class="o-mail-Composer-avatar o_avatar rounded" t-att-src="threadService.avatarUrl(store.self, props.composer.thread)" alt="Avatar of user"/>
|
||||
</div>
|
||||
<div class="o-mail-Composer-coreHeader text-truncate small p-2" t-if="props.composer.thread and props.messageToReplyTo?.thread === props.composer.thread">
|
||||
<span class="cursor-pointer" t-on-click="() => env.messageHighlight?.highlightMessage(props.messageToReplyTo.message.id, props.composer.thread)">
|
||||
<span class="cursor-pointer" t-on-click="() => env.messageHighlight?.highlightMessage(props.messageToReplyTo.message, props.composer.thread)">
|
||||
Replying to <b t-esc="props.messageToReplyTo.message.author.name"/>
|
||||
</span>
|
||||
<span t-if="props.messageToReplyTo.message.originThread !== props.composer.thread">
|
||||
|
||||
@@ -202,7 +202,10 @@ export class Thread extends Component {
|
||||
async onClickNotification(ev) {
|
||||
const { oeType, oeId } = ev.target.dataset;
|
||||
if (oeType === "highlight") {
|
||||
await this.env.messageHighlight?.highlightMessage(Number(oeId), this.props.thread);
|
||||
await this.env.messageHighlight?.highlightMessage(
|
||||
this.store.messages[Number(oeId)],
|
||||
this.props.thread
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
messageToReplyTo="props.messageToReplyTo"
|
||||
squashed="isSquashed(msg, prevMsg)"
|
||||
highlighted="messageHighlight?.highlightedMessageId === msg.id"
|
||||
onParentMessageClick="() => msg.parentMessage and env.messageHighlight?.highlightMessage(msg.parentMessage.id, props.thread)"
|
||||
onParentMessageClick="() => msg.parentMessage and env.messageHighlight?.highlightMessage(msg.parentMessage, props.thread)"
|
||||
thread="props.thread"
|
||||
messageEdition="props.messageEdition"
|
||||
/>
|
||||
|
||||
@@ -50,7 +50,7 @@ export class PinnedMessagesPanel extends Component {
|
||||
// to the message.
|
||||
await new Promise((resolve) => setTimeout(() => requestAnimationFrame(resolve)));
|
||||
}
|
||||
await this.env.messageHighlight?.highlightMessage(message.id, this.props.thread);
|
||||
await this.env.messageHighlight?.highlightMessage(message, this.props.thread);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -240,15 +240,22 @@ export function useMessageHighlight(duration = 2000) {
|
||||
let timeout;
|
||||
const threadService = useService("mail.thread");
|
||||
const state = useState({
|
||||
async highlightMessage(msgId, thread) {
|
||||
await threadService.loadAround(thread, msgId);
|
||||
/**
|
||||
* @param {import("@mail/core/message_model").Message} message
|
||||
* @param {import("@mail/core/thread_model").Thread} thread
|
||||
*/
|
||||
async highlightMessage(message, thread) {
|
||||
if (message.originThread.localId !== thread.localId) {
|
||||
return;
|
||||
}
|
||||
await threadService.loadAround(thread, message.id);
|
||||
const lastHighlightedMessageId = state.highlightedMessageId;
|
||||
clearHighlight();
|
||||
if (lastHighlightedMessageId === msgId) {
|
||||
if (lastHighlightedMessageId === message.id) {
|
||||
// Give some time for the state to update.
|
||||
await new Promise(setTimeout);
|
||||
}
|
||||
state.highlightedMessageId = msgId;
|
||||
state.highlightedMessageId = message.id;
|
||||
timeout = setTimeout(clearHighlight, duration);
|
||||
},
|
||||
highlightedMessageId: null,
|
||||
|
||||
Reference in New Issue
Block a user