Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
8c011974
Commit
8c011974
authored
Mar 04, 2024
by
Danny Liu
Browse files
refac: reassign grandchildren of deleted message as children of parent message
parent
22503873
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
7 deletions
+27
-7
src/lib/components/chat/Messages.svelte
src/lib/components/chat/Messages.svelte
+27
-7
No files found.
src/lib/components/chat/Messages.svelte
View file @
8c011974
...
...
@@ -224,15 +224,35 @@
};
const messageDeleteHandler = async (messageId) => {
const messageParentId = history.messages[messageId]?.parentId;
if (messageParentId !== null) {
const messageToDelete = history.messages[messageId];
const messageParentId = messageToDelete.parentId;
const messageChildrenIds = messageToDelete.childrenIds ?? [];
messageChildrenIds.forEach((childId) => {
const child = history.messages[childId];
if (child && child.childrenIds) {
if (child.childrenIds.length == 0) { // if last prompt/response pair
history.messages[messageParentId].childrenIds = []
history.currentId = messageParentId;
}
else {
child.childrenIds.forEach((grandChildId) => {
if (history.messages[grandChildId]) {
history.messages[grandChildId].parentId = messageParentId;
history.messages[messageParentId].childrenIds.push(grandChildId);
}
});
}
}
history.currentId = messageParentId;
// remove response
history.messages[messageParentId].childrenIds = history.messages[messageParentId].childrenIds
.filter((id) => id !== childId);
});
await tick();
// remove prompt
history.messages[messageParentId].childrenIds = history.messages[messageParentId].childrenIds
.filter((id) => id !== messageId);
await updateChatById(localStorage.token, chatId, {
messages: messages,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment