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

Add LogIn/LogOut event handlers to NativeShell

This commit is contained in:
Dmitry Lyzo 2021-04-11 13:58:48 +03:00
parent 98814a5b66
commit 6b5eca7631

View file

@ -8,8 +8,12 @@ class ServerConnections extends ConnectionManager {
super(...arguments);
this.localApiClient = null;
Events.on(this, 'localusersignedout', function () {
Events.on(this, 'localusersignedout', function (eventName, logoutInfo) {
setUserInfo(null, null);
if (window.NativeShell && typeof window.NativeShell.onLocalUserSignedOut === 'function') {
window.NativeShell.onLocalUserSignedOut(logoutInfo);
}
});
}
@ -62,7 +66,12 @@ class ServerConnections extends ConnectionManager {
onLocalUserSignedIn(user) {
const apiClient = this.getApiClient(user.ServerId);
this.setLocalApiClient(apiClient);
return setUserInfo(user.Id, apiClient);
return setUserInfo(user.Id, apiClient).then(() => {
if (window.NativeShell && typeof window.NativeShell.onLocalUserSignedIn === 'function') {
return window.NativeShell.onLocalUserSignedIn(user, apiClient.accessToken());
}
return Promise.resolve();
});
}
}