From 723a5a050e2535164e9dd890b2c37bc353ee7d20 Mon Sep 17 00:00:00 2001 From: J Date: Fri, 26 Feb 2021 20:29:05 +0000 Subject: [PATCH] interface: check accessKey !== undefined Also make it type-level optional rather than using explicit null. Perhaps one day we will want to use undefined to denote "the thread hasn't returned yet" and null for "GCP Storage is not configured." Perhaps. --- pkg/interface/src/logic/lib/useStorage.ts | 2 +- pkg/interface/src/logic/store/store.ts | 4 +--- pkg/interface/src/types/gcp-state.ts | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/interface/src/logic/lib/useStorage.ts b/pkg/interface/src/logic/lib/useStorage.ts index 2fd01932e2..a85549e006 100644 --- a/pkg/interface/src/logic/lib/useStorage.ts +++ b/pkg/interface/src/logic/lib/useStorage.ts @@ -23,7 +23,7 @@ const useStorage = (s3: S3State, gcp: GcpState, useEffect(() => { // prefer GCP if available, else use S3. - if (gcp.accessKey) { + if (gcp.accessKey !== undefined) { client.current = new GcpClient(gcp.accessKey); } else { if (!s3.credentials) { diff --git a/pkg/interface/src/logic/store/store.ts b/pkg/interface/src/logic/store/store.ts index 85d1ef0e12..af6708747f 100644 --- a/pkg/interface/src/logic/store/store.ts +++ b/pkg/interface/src/logic/store/store.ts @@ -73,9 +73,7 @@ export default class GlobalStore extends BaseStore { }, weather: {}, userLocation: null, - gcp: { - accessKey: null - }, + gcp: {}, s3: { configuration: { buckets: new Set(), diff --git a/pkg/interface/src/types/gcp-state.ts b/pkg/interface/src/types/gcp-state.ts index 41ebe12501..976214af42 100644 --- a/pkg/interface/src/types/gcp-state.ts +++ b/pkg/interface/src/types/gcp-state.ts @@ -4,5 +4,5 @@ export interface GcpToken { }; export interface GcpState { - accessKey: string; + accessKey?: string; };