not show loading on reload to prevent scollable jumpy
This commit is contained in:
@@ -191,8 +191,14 @@ export function useEditorAgentConversation({
|
||||
);
|
||||
|
||||
const loadConversation = useCallback(
|
||||
async (conversationId: string) => {
|
||||
setIsLoadingMessages(true);
|
||||
async (
|
||||
conversationId: string,
|
||||
options: { showLoading?: boolean } = {},
|
||||
) => {
|
||||
const showLoading = options.showLoading ?? true;
|
||||
if (showLoading) {
|
||||
setIsLoadingMessages(true);
|
||||
}
|
||||
setErrorMessage(null);
|
||||
try {
|
||||
const detail = await client.getConversation(conversationId);
|
||||
@@ -204,7 +210,9 @@ export function useEditorAgentConversation({
|
||||
);
|
||||
throw error;
|
||||
} finally {
|
||||
setIsLoadingMessages(false);
|
||||
if (showLoading) {
|
||||
setIsLoadingMessages(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
[applyConversationDetail, client],
|
||||
@@ -298,7 +306,7 @@ export function useEditorAgentConversation({
|
||||
if (!conversationId) {
|
||||
return null;
|
||||
}
|
||||
return loadConversation(conversationId);
|
||||
return loadConversation(conversationId, { showLoading: false });
|
||||
}, [loadConversation]);
|
||||
|
||||
const requestCanvasRefreshForMessages = useCallback(
|
||||
@@ -443,7 +451,9 @@ export function useEditorAgentConversation({
|
||||
return;
|
||||
}
|
||||
|
||||
const detail = await loadConversation(conversationId);
|
||||
const detail = await loadConversation(conversationId, {
|
||||
showLoading: false,
|
||||
});
|
||||
const updatedMessage = detail.messages.find(
|
||||
(message) => message.id === messageId,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user