2023-09-10 23:20:20 +03:30
|
|
|
import { appRouter } from './router/appRouter';
|
|
|
|
import browser from '../scripts/browser';
|
|
|
|
import dialog from './dialog/dialog';
|
2024-08-14 13:31:34 -04:00
|
|
|
import globalize from '../lib/globalize';
|
2020-07-15 14:46:56 +01:00
|
|
|
|
2023-07-26 10:28:14 +03:30
|
|
|
export default async function (text, title) {
|
|
|
|
// Modals seem to be blocked on Web OS and Tizen 2.x
|
|
|
|
const canUseNativeAlert = !!(
|
2023-09-10 23:20:20 +03:30
|
|
|
!browser.web0s
|
2025-01-22 03:12:45 -05:00
|
|
|
&& !(browser.tizenVersion && (browser.tizenVersion < 3 || browser.tizenVersion >= 8))
|
2023-09-10 23:20:20 +03:30
|
|
|
&& browser.tv
|
|
|
|
&& window.alert
|
2023-07-26 10:27:40 +03:30
|
|
|
);
|
2023-04-19 01:56:05 -04:00
|
|
|
|
2023-09-10 23:20:20 +03:30
|
|
|
const options = typeof text === 'string' ? { title, text } : text;
|
2021-10-03 10:32:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
await appRouter.ready();
|
2021-10-27 00:07:59 +03:00
|
|
|
|
2023-07-26 10:28:14 +03:30
|
|
|
if (canUseNativeAlert) {
|
2023-09-10 23:20:20 +03:30
|
|
|
alert((options.text || '').replaceAll('<br/>', '\n'));
|
2023-07-26 10:28:14 +03:30
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
return Promise.resolve();
|
2023-07-26 10:28:14 +03:30
|
|
|
}
|
2019-02-23 19:14:56 +00:00
|
|
|
|
2023-09-12 22:04:18 +03:30
|
|
|
options.buttons = [
|
2023-07-26 10:28:14 +03:30
|
|
|
{
|
2023-09-10 23:20:20 +03:30
|
|
|
name: globalize.translate('ButtonGotIt'),
|
|
|
|
id: 'ok',
|
|
|
|
type: 'submit'
|
|
|
|
}
|
2023-07-26 10:28:14 +03:30
|
|
|
];
|
2019-02-23 19:14:56 +00:00
|
|
|
|
2023-07-26 10:28:14 +03:30
|
|
|
return dialog.show(options);
|
2023-04-19 01:56:05 -04:00
|
|
|
}
|