From 527215e0f046fe8f666334f09c209ea6e2c34a58 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sun, 3 Oct 2021 10:32:37 +0300 Subject: [PATCH] Use custom modals on webOS and Tizen 2.x --- src/components/alert.js | 11 ++++++++++- src/components/confirm/confirm.js | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/alert.js b/src/components/alert.js index f6339489f3..7d3ef34dff 100644 --- a/src/components/alert.js +++ b/src/components/alert.js @@ -10,6 +10,15 @@ import globalize from '../scripts/globalize'; return originalString.replace(reg, strWith); } + function useNativeAlert() { + // webOS seems to block modals + // Tizen 2.x seems to block modals + return !browser.web0s + && !(browser.tizenVersion && browser.tizenVersion < 3) + && browser.tv + && window.alert; + } + export default async function (text, title) { let options; if (typeof text === 'string') { @@ -21,7 +30,7 @@ import globalize from '../scripts/globalize'; options = text; } - if (browser.tv && window.alert) { + if (useNativeAlert()) { await appRouter.ready(); alert(replaceAll(options.text || '', '
', '\n')); return Promise.resolve(); diff --git a/src/components/confirm/confirm.js b/src/components/confirm/confirm.js index 7fe7fb9832..ac2315f533 100644 --- a/src/components/confirm/confirm.js +++ b/src/components/confirm/confirm.js @@ -7,6 +7,15 @@ function replaceAll(str, find, replace) { return str.split(find).join(replace); } +function useNativeConfirm() { + // webOS seems to block modals + // Tizen 2.x seems to block modals + return !browser.web0s + && !(browser.tizenVersion && browser.tizenVersion < 3) + && browser.tv + && window.confirm; +} + async function nativeConfirm(options) { if (typeof options === 'string') { options = { @@ -62,6 +71,6 @@ function customConfirm(text, title) { }); } -const confirm = browser.tv && window.confirm ? nativeConfirm : customConfirm; +const confirm = useNativeConfirm() ? nativeConfirm : customConfirm; export default confirm;