mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 00:58:32 +02:00
Fix text streaming breaking scroll
This commit is contained in:
@@ -100,8 +100,7 @@ export function TextViewer({ language, text, responseId, requestId, pretty, clas
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const formattedBody = useFormatText({ text, language, pretty });
|
const formattedBody = useFormatText({ text, language, pretty });
|
||||||
|
if (formattedBody == null) {
|
||||||
if (formattedBody.data == null) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +112,7 @@ export function TextViewer({ language, text, responseId, requestId, pretty, clas
|
|||||||
body = filteredResponse.data != null ? filteredResponse.data : '';
|
body = filteredResponse.data != null ? filteredResponse.data : '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
body = formattedBody.data;
|
body = formattedBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode unicode sequences in the text to readable characters
|
// Decode unicode sequences in the text to readable characters
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { tryFormatJson, tryFormatXml } from '../lib/formatters';
|
|
||||||
import type { EditorProps } from '../components/core/Editor/Editor';
|
import type { EditorProps } from '../components/core/Editor/Editor';
|
||||||
|
import { tryFormatJson, tryFormatXml } from '../lib/formatters';
|
||||||
|
|
||||||
export function useFormatText({
|
export function useFormatText({
|
||||||
text,
|
text,
|
||||||
@@ -12,6 +12,7 @@ export function useFormatText({
|
|||||||
pretty: boolean;
|
pretty: boolean;
|
||||||
}) {
|
}) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
|
placeholderData: (prev) => prev, // Keep previous data on refetch
|
||||||
queryKey: [text, language, pretty],
|
queryKey: [text, language, pretty],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (text === '' || !pretty) {
|
if (text === '' || !pretty) {
|
||||||
@@ -24,5 +25,5 @@ export function useFormatText({
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
}).data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user