diff --git a/src/components/alert.js b/src/components/alert.js index f8d499934..ff5165590 100644 --- a/src/components/alert.js +++ b/src/components/alert.js @@ -1,27 +1,12 @@ import { appRouter } from './router/appRouter'; -import browser from '../scripts/browser'; import dialog from './dialog/dialog'; import globalize from '../lib/globalize'; export default async function (text, title) { - // Modals seem to be blocked on Web OS and Tizen 2.x - const canUseNativeAlert = !!( - !browser.web0s - && !(browser.tizenVersion && (browser.tizenVersion < 3 || browser.tizenVersion >= 8)) - && browser.tv - && window.alert - ); - const options = typeof text === 'string' ? { title, text } : text; await appRouter.ready(); - if (canUseNativeAlert) { - alert((options.text || '').replaceAll('
', '\n')); - - return Promise.resolve(); - } - options.buttons = [ { name: globalize.translate('ButtonGotIt'), diff --git a/src/components/confirm/confirm.ts b/src/components/confirm/confirm.ts index 3b40a8f2b..5301fc79b 100644 --- a/src/components/confirm/confirm.ts +++ b/src/components/confirm/confirm.ts @@ -1,7 +1,6 @@ import dialog from 'components/dialog/dialog'; import { appRouter } from 'components/router/appRouter'; import globalize from 'lib/globalize'; -import browser from 'scripts/browser'; interface OptionItem { id: string, @@ -18,34 +17,7 @@ interface ConfirmOptions { buttons?: OptionItem[] } -function shouldUseNativeConfirm() { - // webOS seems to block modals - // Tizen 2.x seems to block modals - return !browser.web0s - && !(browser.tizenVersion && (browser.tizenVersion < 3 || browser.tizenVersion >= 8)) - && browser.tv - && !!window.confirm; -} - -async function nativeConfirm(options: string | ConfirmOptions) { - if (typeof options === 'string') { - options = { - text: options - } as ConfirmOptions; - } - - const text = (options.text || '').replace(//g, '\n'); - await appRouter.ready(); - const result = window.confirm(text); - - if (result) { - return Promise.resolve(); - } else { - return Promise.reject(new Error('Confirm dialog rejected')); - } -} - -async function customConfirm(options: string | ConfirmOptions, title: string = '') { +async function confirm(options: string | ConfirmOptions, title: string = '') { if (typeof options === 'string') { options = { title, @@ -80,6 +52,4 @@ async function customConfirm(options: string | ConfirmOptions, title: string = ' }); } -const confirm = shouldUseNativeConfirm() ? nativeConfirm : customConfirm; - export default confirm; diff --git a/src/components/prompt/prompt.js b/src/components/prompt/prompt.js index 64295f722..d131fcd0a 100644 --- a/src/components/prompt/prompt.js +++ b/src/components/prompt/prompt.js @@ -1,4 +1,3 @@ -import browser from '../../scripts/browser'; import dialogHelper from '../dialogHelper/dialogHelper'; import layoutManager from '../layoutManager'; import scrollHelper from '../../scripts/scrollHelper'; @@ -92,33 +91,13 @@ export default (() => { }); } - if ((browser.tv || browser.xboxOne) && window.confirm) { - return options => { - if (typeof options === 'string') { - options = { - label: '', - text: options - }; - } - - const label = (options.label || '').replaceAll('
', '\n'); - const result = prompt(label, options.text || ''); - - if (result) { - return Promise.resolve(result); - } else { - return Promise.reject(result); - } - }; - } else { - return options => { - if (typeof options === 'string') { - options = { - title: '', - text: options - }; - } - return showDialog(options); - }; - } + return options => { + if (typeof options === 'string') { + options = { + title: '', + text: options + }; + } + return showDialog(options); + }; })();