2021-10-03 21:51:06 +03:00
|
|
|
import { appRouter } from './appRouter';
|
2020-08-14 08:46:34 +02:00
|
|
|
import browser from '../scripts/browser';
|
|
|
|
import dialog from './dialog/dialog';
|
|
|
|
import globalize from '../scripts/globalize';
|
2020-07-15 14:46:56 +01:00
|
|
|
|
2020-07-20 08:40:13 +01:00
|
|
|
/* eslint-disable indent */
|
2019-02-23 19:14:56 +00:00
|
|
|
|
2021-10-03 10:32:37 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-10-03 21:51:06 +03:00
|
|
|
export default async function (text, title) {
|
2020-07-20 08:40:13 +01:00
|
|
|
let options;
|
2019-02-23 19:14:56 +00:00
|
|
|
if (typeof text === 'string') {
|
|
|
|
options = {
|
|
|
|
title: title,
|
|
|
|
text: text
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
options = text;
|
|
|
|
}
|
|
|
|
|
2021-10-27 00:07:59 +03:00
|
|
|
await appRouter.ready();
|
|
|
|
|
2021-10-03 10:32:37 +03:00
|
|
|
if (useNativeAlert()) {
|
2022-10-15 00:27:25 -04:00
|
|
|
alert((options.text || '').replaceAll('<br/>', '\n'));
|
2021-10-03 21:51:06 +03:00
|
|
|
return Promise.resolve();
|
2019-02-23 19:14:56 +00:00
|
|
|
} else {
|
2020-07-20 08:40:13 +01:00
|
|
|
const items = [];
|
2019-02-23 19:14:56 +00:00
|
|
|
|
|
|
|
items.push({
|
|
|
|
name: globalize.translate('ButtonGotIt'),
|
|
|
|
id: 'ok',
|
|
|
|
type: 'submit'
|
|
|
|
});
|
|
|
|
|
|
|
|
options.buttons = items;
|
2021-02-06 15:51:31 +09:00
|
|
|
return dialog.show(options);
|
2019-02-23 19:14:56 +00:00
|
|
|
}
|
2020-07-15 14:46:56 +01:00
|
|
|
}
|
|
|
|
|
2020-07-20 08:40:13 +01:00
|
|
|
/* eslint-enable indent */
|