1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/components/alert.js

37 lines
904 B
JavaScript
Raw Normal View History

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-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-07-26 10:27:40 +03:30
!browser.web0s &&
!(browser.tizenVersion && browser.tizenVersion < 3) &&
browser.tv &&
window.alert
);
2023-04-19 01:56:05 -04:00
2023-07-26 10:28:14 +03:30
let options = typeof text === "string" ? { title, text } : text;
2023-04-19 01:56:05 -04:00
await appRouter.ready();
2023-07-26 10:28:14 +03:30
if (canUseNativeAlert) {
2023-07-26 10:27:40 +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
}
2023-07-26 10:28:14 +03:30
const items = [
{
2023-07-26 10:27:40 +03:30
name: globalize.translate("ButtonGotIt"),
id: "ok",
type: "submit",
2023-07-26 10:28:14 +03:30
},
];
2023-07-26 10:28:14 +03:30
options.buttons = items;
return dialog.show(options);
2023-04-19 01:56:05 -04:00
}