Prevent ephemeral message extra changes vanish upon swiping

This commit is contained in:
Cohee
2025-01-28 15:39:09 +00:00
parent 3a8a329b0f
commit 0c9b301a57
2 changed files with 23 additions and 0 deletions

View File

@ -6074,6 +6074,19 @@ export async function saveReply(type, getMessage, fromStreaming, title, swipes,
return { type, getMessage };
}
export function syncCurrentSwipeInfoExtras() {
if (!chat.length) {
return;
}
const currentMessage = chat[chat.length - 1];
if (currentMessage && Array.isArray(currentMessage.swipe_info) && typeof currentMessage.swipe_id === 'number') {
const swipeInfo = currentMessage.swipe_info[currentMessage.swipe_id];
if (swipeInfo && typeof swipeInfo === 'object') {
swipeInfo.extra = structuredClone(currentMessage.extra);
}
}
}
function saveImageToMessage(img, mes) {
if (mes && img.image) {
if (!mes.extra || typeof mes.extra !== 'object') {
@ -8501,6 +8514,9 @@ function swipe_left() { // when we swipe left..but no generation.
streamingProcessor.onStopStreaming();
}
// Make sure ad-hoc changes to extras are saved before swiping away
syncCurrentSwipeInfoExtras();
const swipe_duration = 120;
const swipe_range = '700px';
chat[chat.length - 1]['swipe_id']--;
@ -8636,6 +8652,9 @@ const swipe_right = () => {
return unblockGeneration();
}
// Make sure ad-hoc changes to extras are saved before swiping away
syncCurrentSwipeInfoExtras();
const swipe_duration = 200;
const swipe_range = 700;
//console.log(swipe_range);