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

Merge pull request #4730 from sttatusx/refactor-alert-js

Refactor alert js
This commit is contained in:
Bill Thornton 2023-09-12 15:35:14 -04:00 committed by GitHub
commit 74920c9f96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,41 +3,32 @@ import browser from '../scripts/browser';
import dialog from './dialog/dialog';
import globalize from '../scripts/globalize';
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;
}
export default async function (text, title) {
let options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
options = text;
}
// Modals seem to be blocked on Web OS and Tizen 2.x
const canUseNativeAlert = !!(
!browser.web0s
&& !(browser.tizenVersion && browser.tizenVersion < 3)
&& browser.tv
&& window.alert
);
const options = typeof text === 'string' ? { title, text } : text;
await appRouter.ready();
if (useNativeAlert()) {
if (canUseNativeAlert) {
alert((options.text || '').replaceAll('<br/>', '\n'));
return Promise.resolve();
} else {
const items = [];
items.push({
return Promise.resolve();
}
options.buttons = [
{
name: globalize.translate('ButtonGotIt'),
id: 'ok',
type: 'submit'
});
}
];
options.buttons = items;
return dialog.show(options);
}
return dialog.show(options);
}