fix: ensure cross-platform compatibility with file exports (#4336)

This commit is contained in:
James George
2024-09-10 00:23:33 -07:00
committed by GitHub
parent 3b29a56ba0
commit a395643387
8 changed files with 114 additions and 107 deletions

View File

@@ -48,7 +48,7 @@ import { getTeamCollectionJSON } from "~/helpers/backend/helpers"
import { platform } from "~/platform"
import { initializeDownloadCollection } from "~/helpers/import-export/export"
import { initializeDownloadFile } from "~/helpers/import-export/export"
import { gistExporter } from "~/helpers/import-export/export/gist"
import { myCollectionsExporter } from "~/helpers/import-export/export/myCollections"
import { teamCollectionsExporter } from "~/helpers/import-export/export/teamCollections"
@@ -389,27 +389,27 @@ const HoppMyCollectionsExporter: ImporterOrExporter = {
applicableTo: ["personal-workspace"],
isLoading: isHoppMyCollectionExporterInProgress,
},
action: () => {
action: async () => {
if (!myCollections.value.length) {
return toast.error(t("error.no_collections_to_export"))
}
isHoppMyCollectionExporterInProgress.value = true
const message = initializeDownloadCollection(
const message = await initializeDownloadFile(
myCollectionsExporter(myCollections.value),
"Collections"
"hoppscotch-personal-collections"
)
if (E.isRight(message)) {
toast.success(t(message.right))
E.isRight(message)
? toast.success(t(message.right))
: toast.error(t(message.left))
platform.analytics?.logEvent({
type: "HOPP_EXPORT_COLLECTION",
exporter: "json",
platform: "rest",
})
}
platform.analytics?.logEvent({
type: "HOPP_EXPORT_COLLECTION",
exporter: "json",
platform: "rest",
})
isHoppMyCollectionExporterInProgress.value = false
},
@@ -436,7 +436,14 @@ const HoppTeamCollectionsExporter: ImporterOrExporter = {
)
if (E.isRight(res)) {
initializeDownloadCollection(res.right, "team-collections")
const message = await initializeDownloadFile(
res.right,
"hoppscotch-team-collections"
)
E.isRight(message)
? toast.success(t(message.right))
: toast.error(t(message.left))
platform.analytics?.logEvent({
type: "HOPP_EXPORT_COLLECTION",

View File

@@ -21,7 +21,7 @@ import { GistSource } from "~/helpers/import-export/import/import-sources/GistSo
import IconFolderPlus from "~icons/lucide/folder-plus"
import IconUser from "~icons/lucide/user"
import { initializeDownloadCollection } from "~/helpers/import-export/export"
import { initializeDownloadFile } from "~/helpers/import-export/export"
import { useReadonlyStream } from "~/composables/stream"
import { platform } from "~/platform"
@@ -133,14 +133,14 @@ const GqlCollectionsHoppExporter: ImporterOrExporter = {
disabled: false,
applicableTo: ["personal-workspace", "team-workspace"],
},
action: () => {
action: async () => {
if (!gqlCollections.value.length) {
return toast.error(t("error.no_collections_to_export"))
}
const message = initializeDownloadCollection(
const message = await initializeDownloadFile(
gqlCollectionsExporter(gqlCollections.value),
"GQLCollections"
"hoppscotch-gql-collections"
)
if (E.isLeft(message)) {