mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 22:43:11 +02:00
Fix flash loading response viewer
This commit is contained in:
@@ -37,7 +37,7 @@ export function TextViewer({ response, pretty, className }: Props) {
|
||||
);
|
||||
|
||||
const contentType = useContentTypeFromHeaders(response.headers);
|
||||
const rawBody = useResponseBodyText(response) ?? null;
|
||||
const rawBody = useResponseBodyText(response);
|
||||
const isSearching = filterText != null;
|
||||
|
||||
const filteredResponse = useFilterResponse({
|
||||
@@ -99,7 +99,11 @@ export function TextViewer({ response, pretty, className }: Props) {
|
||||
return result;
|
||||
}, [canFilter, filterText, isJson, isSearching, response.id, setFilterText, toggleSearch]);
|
||||
|
||||
if (rawBody == null) {
|
||||
if (rawBody.isLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (rawBody.data == null) {
|
||||
return <BinaryViewer response={response} />;
|
||||
}
|
||||
|
||||
@@ -109,10 +113,11 @@ export function TextViewer({ response, pretty, className }: Props) {
|
||||
|
||||
const formattedBody =
|
||||
pretty && contentType?.includes('json')
|
||||
? tryFormatJson(rawBody)
|
||||
? tryFormatJson(rawBody.data)
|
||||
: pretty && contentType?.includes('xml')
|
||||
? tryFormatXml(rawBody)
|
||||
: rawBody;
|
||||
? tryFormatXml(rawBody.data)
|
||||
: rawBody.data;
|
||||
|
||||
const body = isSearching && filterText?.length > 0 ? filteredResponse : formattedBody;
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user