[FIX] mail: remove message reaction was not working
Follow-up PR of https://github.com/odoo/odoo/pull/136308 Commit above simplified code in discuss models so code applies on records than properties on records. For example, instead of juggling between persona local id and persona, some code can simply keep logic on persona without leaking local id. However the improvements are iterative, and more improvements are needed to stop using local id. Some code still need local ids. Commit above mistakenly converts a local id to persona on some code that still work in terms of local id. As a result, message reactions were not working properly, notably when adding a new reaction using click on an existing message reaction of someone else. There was also a bug in implementation in mock server which made the test not working. This commit fixes this issue too. Task-3523101 closes odoo/odoo#136940 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -13,9 +13,10 @@ export class MessageReactions extends Record {
|
||||
* @returns {import("models").MessageReactions}
|
||||
*/
|
||||
static insert(data) {
|
||||
let reaction = this.store.Message.get(data.message.id)?.reactions.find(
|
||||
({ content }) => content === data.content
|
||||
);
|
||||
if (data.message && !(data.message instanceof Record)) {
|
||||
data.message = this.store.Message.insert(data.message);
|
||||
}
|
||||
let reaction = data.message.reactions.find(({ content }) => content === data.content);
|
||||
if (!reaction) {
|
||||
/** @type {import("models").MessageReactions} */
|
||||
reaction = this.preinsert(data);
|
||||
@@ -46,7 +47,7 @@ export class MessageReactions extends Record {
|
||||
count: data.count,
|
||||
content: data.content,
|
||||
message: data.message,
|
||||
personas: reaction.personas.filter((p) => !personasToUnlink.has(p)),
|
||||
personas: reaction.personas.filter((p) => !personasToUnlink.has(p.localId)),
|
||||
});
|
||||
return reaction;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,10 @@ patch(MockServer.prototype, {
|
||||
guests: [],
|
||||
message: { id: messageId },
|
||||
partners: [
|
||||
["ADD", { id: this.pyEnv.currentPartnerId, name: currentPartner.name }],
|
||||
[
|
||||
action === "add" ? "ADD" : "DELETE",
|
||||
{ id: this.pyEnv.currentPartnerId, name: currentPartner.name },
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -531,6 +531,8 @@ QUnit.test("Two users reacting with the same emoji", async () => {
|
||||
await contains(".o-mail-MessageReaction", { text: "😅2" });
|
||||
await click(".o-mail-MessageReaction");
|
||||
await contains(".o-mail-MessageReaction", { text: "😅1" });
|
||||
await click(".o-mail-MessageReaction");
|
||||
await contains(".o-mail-MessageReaction", { text: "😅2" });
|
||||
});
|
||||
|
||||
QUnit.test("Reaction summary", async () => {
|
||||
|
||||
Reference in New Issue
Block a user