2023-07-26 10:27:40 +03:30
|
|
|
import { appRouter } from "./router/appRouter";
|
|
|
|
import browser from "../scripts/browser";
|
|
|
|
import dialog from "./dialog/dialog";
|
|
|
|
import globalize from "../scripts/globalize";
|
2020-07-15 14:46:56 +01:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function useNativeAlert() {
|
|
|
|
// webOS seems to block modals
|
|
|
|
// Tizen 2.x seems to block modals
|
2023-07-26 10:27:40 +03:30
|
|
|
return (
|
|
|
|
!browser.web0s &&
|
|
|
|
!(browser.tizenVersion && browser.tizenVersion < 3) &&
|
|
|
|
browser.tv &&
|
|
|
|
window.alert
|
|
|
|
);
|
2023-04-19 01:56:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default async function (text, title) {
|
|
|
|
let options;
|
2023-07-26 10:27:40 +03:30
|
|
|
if (typeof text === "string") {
|
2023-04-19 01:56:05 -04:00
|
|
|
options = {
|
|
|
|
title: title,
|
2023-07-26 10:27:40 +03:30
|
|
|
text: text,
|
2023-04-19 01:56:05 -04:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
options = 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-04-19 01:56:05 -04:00
|
|
|
if (useNativeAlert()) {
|
2023-07-26 10:27:40 +03:30
|
|
|
alert((options.text || "").replaceAll("<br/>", "\n"));
|
2023-04-19 01:56:05 -04:00
|
|
|
return Promise.resolve();
|
|
|
|
} else {
|
|
|
|
const items = [];
|
2019-02-23 19:14:56 +00:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
items.push({
|
2023-07-26 10:27:40 +03:30
|
|
|
name: globalize.translate("ButtonGotIt"),
|
|
|
|
id: "ok",
|
|
|
|
type: "submit",
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
2019-02-23 19:14:56 +00:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
options.buttons = items;
|
|
|
|
return dialog.show(options);
|
2020-07-15 14:46:56 +01:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
}
|