storage: use correct keys

This commit is contained in:
Hunter Miller 2023-06-29 11:08:16 -05:00
parent 78277155fb
commit a137ab6451
3 changed files with 27 additions and 14 deletions

View File

@ -21,7 +21,7 @@
|= upd=update
^- json
=, format
%+ frond:enjs %s3-update
%+ frond:enjs %storage-update
%- pairs:enjs
:~ ?- -.upd
%set-current-bucket [%'setCurrentBucket' s+bucket.upd]

View File

@ -92,8 +92,8 @@ export interface StorageUpdateCredentials {
export interface StorageUpdateConfiguration {
configuration: {
buckets: string[];
currentBucket: string;
buckets: string[];
currentBucket: string;
};
}
@ -125,4 +125,13 @@ export interface StorageUpdateRegion {
setRegion: string;
}
export declare type StorageUpdate = StorageUpdateCredentials | StorageUpdateConfiguration | StorageUpdateCurrentBucket | StorageUpdateAddBucket | StorageUpdateRemoveBucket | StorageUpdateEndpoint | StorageUpdateAccessKeyId | StorageUpdateSecretAccessKey | StorageUpdateRegion;
export declare type StorageUpdate =
| StorageUpdateCredentials
| StorageUpdateConfiguration
| StorageUpdateCurrentBucket
| StorageUpdateAddBucket
| StorageUpdateRemoveBucket
| StorageUpdateEndpoint
| StorageUpdateAccessKeyId
| StorageUpdateSecretAccessKey
| StorageUpdateRegion;

View File

@ -1,6 +1,6 @@
import _ from 'lodash';
import { enableMapSet } from 'immer';
import { BaseStorageState } from '@/gear';
import { BaseStorageState, StorageUpdate } from '@/gear';
import reduce from './reducer';
import {
createState,
@ -32,15 +32,19 @@ export const useStorage = createState<BaseStorageState>(
{},
[
(set, get) =>
createSubscription('storage', '/all', (e) => {
const data = _.get(e, 'storage-update', false);
if (data) {
reduceStateN(get(), data, reduce);
createSubscription(
'storage',
'/all',
(e: { 'storage-update': StorageUpdate }) => {
const data = _.get(e, 'storage-update', false);
if (data) {
reduceStateN(get(), data, reduce);
}
numLoads += 1;
if (numLoads === 2) {
set({ loaded: true });
}
}
numLoads += 1;
if (numLoads === 2) {
set({ loaded: true });
}
}),
),
]
);