refactor: store changes for collections (#2947)
This commit is contained in:
@@ -31,7 +31,7 @@ const defaultGraphqlCollectionState = {
|
|||||||
type RESTCollectionStoreType = typeof defaultRESTCollectionState
|
type RESTCollectionStoreType = typeof defaultRESTCollectionState
|
||||||
type GraphqlCollectionStoreType = typeof defaultGraphqlCollectionState
|
type GraphqlCollectionStoreType = typeof defaultGraphqlCollectionState
|
||||||
|
|
||||||
function navigateToFolderWithIndexPath(
|
export function navigateToFolderWithIndexPath(
|
||||||
collections: HoppCollection<HoppRESTRequest | HoppGQLRequest>[],
|
collections: HoppCollection<HoppRESTRequest | HoppGQLRequest>[],
|
||||||
indexPaths: number[]
|
indexPaths: number[]
|
||||||
) {
|
) {
|
||||||
@@ -97,12 +97,15 @@ const restCollectionDispatchers = defineDispatchers({
|
|||||||
{ state }: RESTCollectionStoreType,
|
{ state }: RESTCollectionStoreType,
|
||||||
{
|
{
|
||||||
collectionIndex,
|
collectionIndex,
|
||||||
collection,
|
partialCollection,
|
||||||
}: { collectionIndex: number; collection: HoppCollection<any> }
|
}: {
|
||||||
|
collectionIndex: number
|
||||||
|
partialCollection: Partial<HoppCollection<any>>
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
state: state.map((col, index) =>
|
state: state.map((col, index) =>
|
||||||
index === collectionIndex ? collection : col
|
index === collectionIndex ? { ...col, ...partialCollection } : col
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -824,13 +827,13 @@ export function getRESTCollection(collectionIndex: number) {
|
|||||||
|
|
||||||
export function editRESTCollection(
|
export function editRESTCollection(
|
||||||
collectionIndex: number,
|
collectionIndex: number,
|
||||||
collection: HoppCollection<HoppRESTRequest>
|
partialCollection: Partial<HoppCollection<HoppRESTRequest>>
|
||||||
) {
|
) {
|
||||||
restCollectionStore.dispatch({
|
restCollectionStore.dispatch({
|
||||||
dispatcher: "editCollection",
|
dispatcher: "editCollection",
|
||||||
payload: {
|
payload: {
|
||||||
collectionIndex,
|
collectionIndex,
|
||||||
collection,
|
partialCollection: partialCollection,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user