mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #4077 from SillyTavern/fix-mes0-right-swipe
Allow swipe right to generate first message in non-pristine chats
This commit is contained in:
@@ -9377,13 +9377,13 @@ export function swipe_left(_event, { source, repeated } = {}) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the swipe to the right event.
|
* Handles the swipe to the right event.
|
||||||
* @param {JQuery.Event} _event Event.
|
* @param {JQuery.Event} [_event] Event.
|
||||||
* @param {object} params Additional parameters.
|
* @param {object} params Additional parameters.
|
||||||
* @param {string} [params.source] The source of the swipe event.
|
* @param {string} [params.source] The source of the swipe event.
|
||||||
* @param {boolean} [params.repeated] Is the swipe event repeated.
|
* @param {boolean} [params.repeated] Is the swipe event repeated.
|
||||||
*/
|
*/
|
||||||
//MARK: swipe_right
|
//MARK: swipe_right
|
||||||
export function swipe_right(_event, { source, repeated } = {}) {
|
export function swipe_right(_event = null, { source, repeated } = {}) {
|
||||||
if (chat.length - 1 === Number(this_edit_mes_id)) {
|
if (chat.length - 1 === Number(this_edit_mes_id)) {
|
||||||
closeMessageEditor();
|
closeMessageEditor();
|
||||||
}
|
}
|
||||||
@@ -9395,6 +9395,7 @@ export function swipe_right(_event, { source, repeated } = {}) {
|
|||||||
// Make sure ad-hoc changes to extras are saved before swiping away
|
// Make sure ad-hoc changes to extras are saved before swiping away
|
||||||
syncMesToSwipe();
|
syncMesToSwipe();
|
||||||
|
|
||||||
|
const isPristine = !chat_metadata?.tainted;
|
||||||
const swipe_duration = 200;
|
const swipe_duration = 200;
|
||||||
const swipe_range = 700;
|
const swipe_range = 700;
|
||||||
//console.log(swipe_range);
|
//console.log(swipe_range);
|
||||||
@@ -9413,14 +9414,16 @@ export function swipe_right(_event, { source, repeated } = {}) {
|
|||||||
};
|
};
|
||||||
//assign swipe info array with last message from chat
|
//assign swipe info array with last message from chat
|
||||||
}
|
}
|
||||||
if (chat.length === 1 && chat[0]['swipe_id'] !== undefined && chat[0]['swipe_id'] === chat[0]['swipes'].length - 1) { // if swipe_right is called on the last alternate greeting, loop back around
|
// if swipe_right is called on the last alternate greeting in pristine chats, loop back around
|
||||||
|
if (chat.length === 1 && chat[0]['swipe_id'] !== undefined && chat[0]['swipe_id'] === chat[0]['swipes'].length - 1 && isPristine) {
|
||||||
chat[0]['swipe_id'] = 0;
|
chat[0]['swipe_id'] = 0;
|
||||||
} else {
|
} else {
|
||||||
// If the user is holding down the key and we're at the last swipe, don't do anything
|
// If the user is holding down the key and we're at the last swipe, don't do anything
|
||||||
if (source === 'keyboard' && repeated && chat[chat.length - 1].swipe_id === chat[chat.length - 1].swipes.length - 1) {
|
if (source === 'keyboard' && repeated && chat[chat.length - 1].swipe_id === chat[chat.length - 1].swipes.length - 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chat[chat.length - 1]['swipe_id']++; // make new slot in array
|
// make new slot in array
|
||||||
|
chat[chat.length - 1]['swipe_id']++;
|
||||||
}
|
}
|
||||||
if (chat[chat.length - 1].extra) {
|
if (chat[chat.length - 1].extra) {
|
||||||
// if message has memory attached - remove it to allow regen
|
// if message has memory attached - remove it to allow regen
|
||||||
@@ -9435,8 +9438,8 @@ export function swipe_right(_event, { source, repeated } = {}) {
|
|||||||
if (!Array.isArray(chat[chat.length - 1]['swipe_info'])) {
|
if (!Array.isArray(chat[chat.length - 1]['swipe_info'])) {
|
||||||
chat[chat.length - 1]['swipe_info'] = [];
|
chat[chat.length - 1]['swipe_info'] = [];
|
||||||
}
|
}
|
||||||
//console.log(chat[chat.length-1]['swipes']);
|
//if swipe id of last message is the same as the length of the 'swipes' array and not the greeting
|
||||||
if (parseInt(chat[chat.length - 1]['swipe_id']) === chat[chat.length - 1]['swipes'].length && chat.length !== 1) { //if swipe id of last message is the same as the length of the 'swipes' array and not the greeting
|
if (parseInt(chat[chat.length - 1]['swipe_id']) === chat[chat.length - 1]['swipes'].length && (chat.length !== 1 || !isPristine)) {
|
||||||
delete chat[chat.length - 1].gen_started;
|
delete chat[chat.length - 1].gen_started;
|
||||||
delete chat[chat.length - 1].gen_finished;
|
delete chat[chat.length - 1].gen_finished;
|
||||||
run_generate = true;
|
run_generate = true;
|
||||||
|
Reference in New Issue
Block a user