[IMP] web: add isDisplayStandalone feature detection helper
This commit adds the isDisplayStandalone helper, allowing to detect whether Odoo is running inside the Progressive Web App (in standalone mode) or not. This feature detection is directly used in the linked enterprise closes odoo/odoo#128969 Pr: https://github.com/odoo/enterprise/pull/43680. Related: odoo/enterprise#43680 Signed-off-by: Pierre Paridans (app) <app@odoo.com>
This commit is contained in:
@@ -33,6 +33,7 @@ export const browser = {
|
||||
cancelAnimationFrame: window.cancelAnimationFrame.bind(window),
|
||||
console: window.console,
|
||||
history: window.history,
|
||||
matchMedia: window.matchMedia.bind(window),
|
||||
navigator,
|
||||
Notification: window.Notification,
|
||||
open: window.open.bind(window),
|
||||
|
||||
@@ -48,6 +48,10 @@ export function isAndroidApp() {
|
||||
return /OdooMobile.+Android/i.test(browser.navigator.userAgent);
|
||||
}
|
||||
|
||||
export function isDisplayStandalone() {
|
||||
return browser.matchMedia("(display-mode: standalone)").matches;
|
||||
}
|
||||
|
||||
export function hasTouch() {
|
||||
return browser.ontouchstart !== undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user