Always store response on filesystem

This commit is contained in:
Gregory Schier
2023-04-13 18:52:56 -07:00
parent 513793d9ce
commit 4f7a116378
2 changed files with 22 additions and 20 deletions

View File

@@ -2,16 +2,16 @@ import { useQuery } from '@tanstack/react-query';
import { readBinaryFile } from '@tauri-apps/api/fs';
import type { HttpResponse } from '../lib/models';
export function useResponseBodyBlob(response: HttpResponse | null) {
export function useResponseBodyBlob(response: HttpResponse) {
return useQuery<Uint8Array | null>({
enabled: response != null,
queryKey: ['response-body-binary', response?.updatedAt],
initialData: null,
queryFn: async () => {
if (response?.body) {
if (response.body) {
return Uint8Array.of(...response.body);
}
if (response?.bodyPath) {
if (response.bodyPath) {
return readBinaryFile(response.bodyPath);
}
return null;