Skip to content

Commit 1aaf7e2

Browse files
ramh-odooalexkuhn
authored andcommitted
[FIX] mail: update systray counter on discard of native notification
Before this commit: When a user discarded the `Turn on notifications` option from the messaging menu, the systray notification counter was not updated. This issue occurred due to an incorrectly written condition. After this commit: The issue is resolved, and the systray notification counter is correctly updated when the user discards the native notification prompt. closes odoo#194700 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
1 parent 239eab1 commit 1aaf7e2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

addons/mail/static/src/core/web/messaging_menu_patch.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ patch(MessagingMenu.prototype, {
9393
displayName: _t("Turn on notifications"),
9494
iconSrc: this.store.odoobot.avatarUrl,
9595
partner: this.store.odoobot,
96-
isShown:
97-
this.store.discuss.activeTab === "main" &&
98-
this.shouldAskPushPermission &&
99-
!this.store.isNotificationPermissionDismissed,
96+
isShown: this.store.discuss.activeTab === "main" && this.shouldAskPushPermission,
10097
};
10198
},
10299
get tabs() {
@@ -180,7 +177,10 @@ patch(MessagingMenu.prototype, {
180177
return this.store.discuss.activeTab !== "channel" && !this.state.adding;
181178
},
182179
get shouldAskPushPermission() {
183-
return this.notification.permission === "prompt";
180+
return (
181+
this.notification.permission === "prompt" &&
182+
!this.store.isNotificationPermissionDismissed
183+
);
184184
},
185185
getFailureNotificationName(failure) {
186186
if (failure.type === "email") {

addons/mail/static/tests/messaging_menu/messaging_menu.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ test("rendering with chat push notification default permissions", async () => {
101101
test("can quickly dismiss 'Turn on notification' suggestion", async () => {
102102
patchBrowserNotification("default");
103103
await start();
104-
await contains(".o-mail-MessagingMenu-counter");
105104
await contains(".o-mail-MessagingMenu-counter", { text: "1" });
106105
await click(".o_menu_systray i[aria-label='Messages']");
107106
await contains(".o-mail-NotificationItem");
108107
await contains(".o-mail-NotificationItem", { text: "Turn on notifications" });
109108
await click(".o-mail-NotificationItem:contains(Turn on notifications) [title='Dismiss']");
110109
await contains(".o-mail-NotificationItem", { text: "Turn on notifications", count: 0 });
110+
await contains(".o-mail-MessagingMenu-counter", { count: 0 });
111111
});
112112

113113
test("rendering with chat push notification permissions denied", async () => {

0 commit comments

Comments
 (0)