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.
This commit is contained in:
J 2021-02-26 20:29:05 +00:00
parent 6b3397bd9f
commit 723a5a050e
3 changed files with 3 additions and 5 deletions

View File

@ -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) {

View File

@ -73,9 +73,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
},
weather: {},
userLocation: null,
gcp: {
accessKey: null
},
gcp: {},
s3: {
configuration: {
buckets: new Set(),

View File

@ -4,5 +4,5 @@ export interface GcpToken {
};
export interface GcpState {
accessKey: string;
accessKey?: string;
};