Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI updates: Add robustness to console storage provider (#1377)

Rich Turner3e6bbaeafd48
diff --git a/ui/component/core/src/console.ts b/ui/component/core/src/console.ts
index 82ec75657..602c38756 100644
--- a/ui/component/core/src/console.ts
+++ b/ui/component/core/src/console.ts
@@ -370,11 +370,13 @@ export class Console {
try {
const response = await Promise.race([responsePromise, new Promise<T>((resolve, reject) => setTimeout(reject, 2000))]);
if (response && response.value) {
- return response.value as T;
+ const value = response.value as T;
+ return value === "null" ? undefined : value;
}
} catch (e) {
console.log("Failed to retrieve data from storage provider");
}
+ return undefined;
}
public addProviderMessageListener(providerAction: ProviderAction, listener: (msg: ProviderMessage) => void) {
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 496485be1..626c6a525 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -892,8 +892,13 @@ export class Manager implements EventProviderFactory {
});
if (!authenticated && offlineToken) {
- this._keycloak.refreshToken = offlineToken;
- authenticated = await this._updateKeycloakAccessToken();
+ try {
+ console.error("SETTING OFFLINE TOKEN");
+ this._keycloak.refreshToken = offlineToken;
+ authenticated = await this._updateKeycloakAccessToken();
+ } catch (e) {
+ console.error("Failed to authenticate using offline token");
+ }
}
if (authenticated) {