X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d6d85de50096eb0053d58c5022fd4e949c830929..46751b9305a7e991d484494facd1f40790254d40:/src/store/resources/resources-actions.ts diff --git a/src/store/resources/resources-actions.ts b/src/store/resources/resources-actions.ts index 0034e7aa5f..e6566ab8ad 100644 --- a/src/store/resources/resources-actions.ts +++ b/src/store/resources/resources-actions.ts @@ -3,29 +3,31 @@ // SPDX-License-Identifier: AGPL-3.0 import { unionize, ofType, UnionOf } from '~/common/unionize'; -import { Resource, extractUuidKind } from '~/models/resource'; +import { extractUuidKind, ResourceTypes } from '~/models/resource'; import { Dispatch } from 'redux'; import { RootState } from '~/store/store'; import { ServiceRepository } from '~/services/services'; import { getResourceService } from '~/services/services'; export const resourcesActions = unionize({ - SET_RESOURCES: ofType(), + SET_RESOURCES: ofType(), DELETE_RESOURCES: ofType() }); export type ResourcesAction = UnionOf; -export const updateResources = (resources: Resource[]) => resourcesActions.SET_RESOURCES(resources); +export const updateResources = (resources: ResourceTypes[]) => resourcesActions.SET_RESOURCES(resources); export const loadResource = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const kind = extractUuidKind(uuid); - const service = getResourceService(kind)(services); - if (service) { - const resource = await service.get(uuid); - dispatch(updateResources([resource])); - return resource; - } + try { + const kind = extractUuidKind(uuid); + const service = getResourceService(kind)(services); + if (service) { + const resource = await service.get(uuid); + dispatch(updateResources([resource])); + return resource; + } + } catch {} return undefined; - }; \ No newline at end of file + };