From 6b5eca7631d5ba0a81acfba208b8c3db0359a2c4 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sun, 11 Apr 2021 13:58:48 +0300 Subject: [PATCH] Add LogIn/LogOut event handlers to NativeShell --- src/components/ServerConnections.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/ServerConnections.js b/src/components/ServerConnections.js index 0242e549cd..e30bdce0c2 100644 --- a/src/components/ServerConnections.js +++ b/src/components/ServerConnections.js @@ -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(); + }); } }