[FIX] mail: do not show Odoobot has a request in mobile

The Odoo mobile app manages push notifications by the app
itself, not the web app. Therefore there's no need to enable
web push notifications.

This commit fixes the issue by considering web push notification
being denied in the mobile app.

closes odoo/odoo#128344

X-original-commit: 045aeaace279d585a7ebefcd5cba7d32207ba9ba
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-07-13 10:46:13 +02:00
parent 0bb419cf11
commit 9726a414e9
2 changed files with 19 additions and 3 deletions
@@ -3,6 +3,7 @@
import { reactive } from "@odoo/owl";
import { browser } from "@web/core/browser/browser";
import { isAndroidApp, isIosApp } from "@web/core/browser/feature_detection";
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
@@ -31,9 +32,12 @@ export const notificationPermissionService = {
}
const state = reactive({
/** @type {"prompt" | "granted" | "denied"} */
permission: this._normalizePermission(
permission?.state ?? browser.Notification?.permission
),
permission:
isIosApp() || isAndroidApp()
? "denied"
: this._normalizePermission(
permission?.state ?? browser.Notification?.permission
),
requestPermission: async () => {
if (browser.Notification && state.permission === "prompt") {
state.permission = this._normalizePermission(
@@ -125,6 +125,18 @@ QUnit.test("respond to notification prompt (granted)", async (assert) => {
assert.verifySteps(["confirmation_granted_toast"]);
});
QUnit.test("no 'OdooBot has a request' in mobile app", async (assert) => {
patchBrowserNotification("default");
// simulate Android Odoo App
patchWithCleanup(browser.navigator, {
userAgent: "Chrome/0.0.0 Android (OdooMobile; Linux; Android 13; Odoo TestSuite)",
});
await start();
assert.containsNone($, ".o-mail-MessagingMenu-counter");
await click(".o_menu_systray i[aria-label='Messages']");
assert.containsNone($, ".o-mail-NotificationItem");
});
QUnit.test("Is closed after clicking on new message", async (assert) => {
await start();
await click(".o_menu_systray i[aria-label='Messages']");