Skip to content

Commit

Permalink
chore: changes to support id based syncing for collections (hoppscotc…
Browse files Browse the repository at this point in the history
  • Loading branch information
amk-dev authored and AndrewBastin committed Apr 11, 2023
1 parent 134441a commit eeee8af
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ const removeCollection = () => {
) {
emit("select", null)
}
removeGraphqlCollection(props.collectionIndex)
removeGraphqlCollection(props.collectionIndex, props.collection.id)
toast.success(`${t("state.deleted")}`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const removeFolder = () => {
emit("select", { picked: null })
}
removeGraphqlFolder(props.folderPath)
removeGraphqlFolder(props.folderPath, props.folder.id)
toast.success(t("state.deleted"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const removeRequest = () => {
emit("select", null)
}
removeGraphqlRequest(props.folderPath, props.requestIndex)
removeGraphqlRequest(props.folderPath, props.requestIndex, props.request.id)
toast.success(`${t("state.deleted")}`)
}
</script>
30 changes: 27 additions & 3 deletions packages/hoppscotch-common/src/components/collections/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ import {
updateRESTRequestOrder,
updateRESTCollectionOrder,
moveRESTFolder,
navigateToFolderWithIndexPath,
restCollectionStore,
} from "~/newstore/collections"
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
import {
Expand Down Expand Up @@ -1014,6 +1016,13 @@ const onRemoveCollection = () => {
if (collectionsType.value.type === "my-collections") {
const collectionIndex = editingCollectionIndex.value
const collectionToRemove =
collectionIndex || collectionIndex == 0
? navigateToFolderWithIndexPath(restCollectionStore.value.state, [
collectionIndex,
])
: undefined
if (collectionIndex === null) return
if (
Expand All @@ -1024,7 +1033,10 @@ const onRemoveCollection = () => {
emit("select", null)
}
removeRESTCollection(collectionIndex)
removeRESTCollection(
collectionIndex,
collectionToRemove ? collectionToRemove.id : undefined
)
resolveSaveContextOnCollectionReorder({
lastIndex: collectionIndex,
Expand Down Expand Up @@ -1077,7 +1089,14 @@ const onRemoveFolder = () => {
emit("select", null)
}
removeRESTFolder(folderPath)
const folderToRemove = folderPath
? navigateToFolderWithIndexPath(
restCollectionStore.value.state,
folderPath.split("/").map((i) => parseInt(i))
)
: undefined
removeRESTFolder(folderPath, folderToRemove ? folderToRemove.id : undefined)
const parentFolder = folderPath.split("/").slice(0, -1).join("/") // remove last folder to get parent folder
resolveSaveContextOnCollectionReorder({
Expand Down Expand Up @@ -1151,7 +1170,12 @@ const onRemoveRequest = () => {
possibleTab.value.document.isDirty = true
}
removeRESTRequest(folderPath, requestIndex)
const requestToRemove = navigateToFolderWithIndexPath(
restCollectionStore.value.state,
folderPath.split("/").map((i) => parseInt(i))
)?.requests[requestIndex]
removeRESTRequest(folderPath, requestIndex, requestToRemove?.id)
// the same function is used to reorder requests since after removing, it's basically doing reorder
resolveSaveContextOnRequestReorder({
Expand Down
Loading

0 comments on commit eeee8af

Please sign in to comment.