chore: merge hoppscotch/staging into self-hosted/main

This commit is contained in:
Andrew Bastin
2023-04-07 03:16:27 +05:30
8 changed files with 114 additions and 100 deletions

View File

@@ -1,6 +1,9 @@
import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data"
import { getTabsRefTo } from "../rest/tab"
import { getAffectedIndexes } from "./affectedIndex"
import { GetSingleRequestDocument } from "../backend/graphql"
import { runGQLQuery } from "../backend/GQLClient"
import * as E from "fp-ts/Either"
/**
* Resolve save context on reorder
@@ -115,6 +118,33 @@ function resetSaveContextForAffectedRequests(folderPath: string) {
}
}
/**
* Reset save context to null if requests are deleted from the team collection or its folder
* only runs when collection or folder is deleted
*/
export async function resetTeamRequestsContext() {
const tabs = getTabsRefTo((tab) => {
return tab.document.saveContext?.originLocation === "team-collection"
})
for (const tab of tabs) {
if (tab.value.document.saveContext?.originLocation === "team-collection") {
const data = await runGQLQuery({
query: GetSingleRequestDocument,
variables: {
requestID: tab.value.document.saveContext?.requestID,
},
})
if (E.isRight(data) && data.right.request === null) {
tab.value.document.saveContext = null
tab.value.document.isDirty = true
}
}
}
}
export function getFoldersByPath(
collections: HoppCollection<HoppRESTRequest>[],
path: string

View File

@@ -45,6 +45,7 @@ export default class TeamEnvironmentAdapter {
this.teamEnvironmentCreated$ = null
this.teamEnvironmentDeleted$ = null
this.teamEnvironmentUpdated$ = null
this.teamEnvironmentCreatedSub = null
this.teamEnvironmentDeletedSub = null
this.teamEnvironmentUpdatedSub = null
@@ -56,6 +57,7 @@ export default class TeamEnvironmentAdapter {
this.teamEnvironmentCreated$?.unsubscribe()
this.teamEnvironmentDeleted$?.unsubscribe()
this.teamEnvironmentUpdated$?.unsubscribe()
this.teamEnvironmentCreatedSub?.unsubscribe()
this.teamEnvironmentDeletedSub?.unsubscribe()
this.teamEnvironmentUpdatedSub?.unsubscribe()