fix: raw lens renderer download option uses direct arraybuffer binary value instead of text

This commit is contained in:
Andrew Bastin
2022-03-01 02:03:30 +05:30
parent f3f9a3a226
commit e9dc7769ac
3 changed files with 39 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
import { pipe } from "fp-ts/function"
import cloneDeep from "lodash/cloneDeep"
import isEqual from "lodash/isEqual"
export const objRemoveKey =
<T, K extends keyof T>(key: K) =>
@@ -8,3 +9,12 @@ export const objRemoveKey =
delete e[key]
return e
})
export const objFieldMatches =
<T, K extends keyof T, V extends T[K]>(
fieldName: K,
matches: ReadonlyArray<V>
) =>
// eslint-disable-next-line no-unused-vars
(obj: T): obj is T & { [_ in K]: V } =>
matches.findIndex((x) => isEqual(obj[fieldName], x)) !== -1

View File

@@ -5,7 +5,7 @@ export type downloadResponseReturnType = (() => void) | Ref<any>
export default function useDownloadResponse(
contentType: string,
responseBodyText: Ref<string>
responseBody: Ref<string | ArrayBuffer>
): {
downloadIcon: Ref<string>
downloadResponse: () => void
@@ -15,7 +15,7 @@ export default function useDownloadResponse(
const t = useI18n()
const downloadResponse = () => {
const dataToWrite = responseBodyText.value
const dataToWrite = responseBody.value
const file = new Blob([dataToWrite], { type: contentType })
const a = document.createElement("a")
const url = URL.createObjectURL(file)