mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-15 18:08:17 -07:00
Check login before ask for notification permission
Previously the user is interrupted on first login with a popup to allow notifications. Now the popup component checks if the user is logged in already an if not it will listen to input event. Resolves: #3243
This commit is contained in:
parent
bb77009f44
commit
3efda93208
@ -3,6 +3,7 @@ import { playbackManager } from '../playback/playbackmanager';
|
||||
import Events from '../../utils/events.ts';
|
||||
import globalize from '../../scripts/globalize';
|
||||
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
|
||||
import ServerConnections from '../../components/ServerConnections';
|
||||
|
||||
import NotificationIcon from './notificationicon.png';
|
||||
|
||||
@ -16,9 +17,27 @@ function onOneDocumentClick() {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
}
|
||||
function registerOneDocumentClickHandler() {
|
||||
Events.off(ServerConnections, 'localusersignedin', registerOneDocumentClickHandler);
|
||||
|
||||
document.addEventListener('click', onOneDocumentClick);
|
||||
document.addEventListener('keydown', onOneDocumentClick);
|
||||
document.addEventListener('click', onOneDocumentClick);
|
||||
document.addEventListener('keydown', onOneDocumentClick);
|
||||
}
|
||||
|
||||
function initPermissionRequest() {
|
||||
const apiClient = ServerConnections.currentApiClient();
|
||||
if (apiClient) {
|
||||
apiClient.getCurrentUser()
|
||||
.then(user => user && registerOneDocumentClickHandler())
|
||||
.catch(() => {
|
||||
Events.on(ServerConnections, 'localusersignedin', registerOneDocumentClickHandler);
|
||||
});
|
||||
} else {
|
||||
registerOneDocumentClickHandler();
|
||||
}
|
||||
}
|
||||
|
||||
initPermissionRequest();
|
||||
|
||||
let serviceWorkerRegistration;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user