refac
Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com>
This commit is contained in:
co-authored by
Classic298
parent
2beeeb90c2
commit
1f474187a7
@@ -356,9 +356,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const showMessage = async (message, ignoreSettings = false) => {
|
const showMessage = async (message, scroll = true) => {
|
||||||
await tick();
|
|
||||||
|
|
||||||
const _chatId = JSON.parse(JSON.stringify($chatId));
|
const _chatId = JSON.parse(JSON.stringify($chatId));
|
||||||
let _messageId = JSON.parse(JSON.stringify(message.id));
|
let _messageId = JSON.parse(JSON.stringify(message.id));
|
||||||
|
|
||||||
@@ -378,18 +376,19 @@
|
|||||||
|
|
||||||
history.currentId = _messageId;
|
history.currentId = _messageId;
|
||||||
|
|
||||||
await tick();
|
|
||||||
await tick();
|
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
if (($settings?.scrollOnBranchChange ?? true) || ignoreSettings) {
|
if (($settings?.scrollOnBranchChange ?? true) && scroll) {
|
||||||
const messageElement = document.getElementById(`message-${message.id}`);
|
const messageElement = document.getElementById(`message-${message.id}`);
|
||||||
if (messageElement) {
|
if (messageElement) {
|
||||||
messageElement.scrollIntoView({ behavior: 'smooth' });
|
messageElement.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await tick();
|
await tick();
|
||||||
|
await tick();
|
||||||
|
await tick();
|
||||||
|
|
||||||
saveChatHandler(_chatId, history);
|
saveChatHandler(_chatId, history);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -392,12 +392,7 @@
|
|||||||
delete history.messages[id];
|
delete history.messages[id];
|
||||||
});
|
});
|
||||||
|
|
||||||
await tick();
|
showMessage({ id: parentMessageId }, false);
|
||||||
|
|
||||||
showMessage({ id: parentMessageId });
|
|
||||||
|
|
||||||
// Update the chat
|
|
||||||
await updateChat();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerScroll = () => {
|
const triggerScroll = () => {
|
||||||
|
|||||||
@@ -612,6 +612,7 @@
|
|||||||
class=" flex w-full message-{message.id}"
|
class=" flex w-full message-{message.id}"
|
||||||
id="message-{message.id}"
|
id="message-{message.id}"
|
||||||
dir={$settings.chatDirection}
|
dir={$settings.chatDirection}
|
||||||
|
style="scroll-margin-top: 3rem;"
|
||||||
>
|
>
|
||||||
<div class={`shrink-0 ltr:mr-3 rtl:ml-3 hidden @lg:flex mt-1 `}>
|
<div class={`shrink-0 ltr:mr-3 rtl:ml-3 hidden @lg:flex mt-1 `}>
|
||||||
<ProfileImage
|
<ProfileImage
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
class=" flex w-full user-message group"
|
class=" flex w-full user-message group"
|
||||||
dir={$settings.chatDirection}
|
dir={$settings.chatDirection}
|
||||||
id="message-{message.id}"
|
id="message-{message.id}"
|
||||||
|
style="scroll-margin-top: 3rem;"
|
||||||
>
|
>
|
||||||
{#if !($settings?.chatBubble ?? true)}
|
{#if !($settings?.chatBubble ?? true)}
|
||||||
<div class={`shrink-0 ltr:mr-3 rtl:ml-3 mt-1`}>
|
<div class={`shrink-0 ltr:mr-3 rtl:ml-3 mt-1`}>
|
||||||
|
|||||||
Reference in New Issue
Block a user