mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	More safeties for swipes
This commit is contained in:
		| @@ -3945,6 +3945,7 @@ async function getChatResult() { | |||||||
|         if (Array.isArray(alternateGreetings) && alternateGreetings.length > 0) { |         if (Array.isArray(alternateGreetings) && alternateGreetings.length > 0) { | ||||||
|             chat[0]['swipe_id'] = 0; |             chat[0]['swipe_id'] = 0; | ||||||
|             chat[0]['swipes'] = []; |             chat[0]['swipes'] = []; | ||||||
|  |             chat[0]['swipe_info'] = []; | ||||||
|             chat[0]['swipes'][0] = chat[0]['mes']; |             chat[0]['swipes'][0] = chat[0]['mes']; | ||||||
|  |  | ||||||
|             for (let i = 0; i < alternateGreetings.length; i++) { |             for (let i = 0; i < alternateGreetings.length; i++) { | ||||||
| @@ -5939,6 +5940,7 @@ async function createOrEditCharacter(e) { | |||||||
|                         if (Array.isArray(alternateGreetings) && alternateGreetings.length > 0) { |                         if (Array.isArray(alternateGreetings) && alternateGreetings.length > 0) { | ||||||
|                             chat[0]['swipe_id'] = 0; |                             chat[0]['swipe_id'] = 0; | ||||||
|                             chat[0]['swipes'] = []; |                             chat[0]['swipes'] = []; | ||||||
|  |                             chat[0]['swipe_info'] = []; | ||||||
|                             chat[0]['swipes'][0] = chat[0]['mes']; |                             chat[0]['swipes'][0] = chat[0]['mes']; | ||||||
|  |  | ||||||
|                             for (let i = 0; i < alternateGreetings.length; i++) { |                             for (let i = 0; i < alternateGreetings.length; i++) { | ||||||
| @@ -6023,6 +6025,9 @@ function swipe_left() {      // when we swipe left..but no generation. | |||||||
|         if (chat[chat.length - 1]['swipe_id'] === 0) { |         if (chat[chat.length - 1]['swipe_id'] === 0) { | ||||||
|             $(this).css('display', 'none'); |             $(this).css('display', 'none'); | ||||||
|         }*/ // Just in case |         }*/ // Just in case | ||||||
|  |         if (!Array.isArray(chat[chat.length - 1]['swipe_info'])) { | ||||||
|  |             chat[chat.length - 1]['swipe_info'] = []; | ||||||
|  |         } | ||||||
|         let this_mes_div = $(this).parent(); |         let this_mes_div = $(this).parent(); | ||||||
|         let this_mes_block = $(this).parent().children('.mes_block').children('.mes_text'); |         let this_mes_block = $(this).parent().children('.mes_block').children('.mes_text'); | ||||||
|         const this_mes_div_height = this_mes_div[0].scrollHeight; |         const this_mes_div_height = this_mes_div[0].scrollHeight; | ||||||
| @@ -6158,6 +6163,9 @@ const swipe_right = () => { | |||||||
|             delete chat[chat.length - 1].extra.display_text; |             delete chat[chat.length - 1].extra.display_text; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |     if (!Array.isArray(chat[chat.length - 1]['swipe_info'])) { | ||||||
|  |         chat[chat.length - 1]['swipe_info'] = []; | ||||||
|  |     } | ||||||
|     //console.log(chat[chat.length-1]['swipes']); |     //console.log(chat[chat.length-1]['swipes']); | ||||||
|     if (parseInt(chat[chat.length - 1]['swipe_id']) === chat[chat.length - 1]['swipes'].length) { //if swipe id of last message is the same as the length of the 'swipes' array |     if (parseInt(chat[chat.length - 1]['swipe_id']) === chat[chat.length - 1]['swipes'].length) { //if swipe id of last message is the same as the length of the 'swipes' array | ||||||
|         delete chat[chat.length - 1].gen_started; |         delete chat[chat.length - 1].gen_started; | ||||||
| @@ -6165,7 +6173,7 @@ const swipe_right = () => { | |||||||
|         run_generate = true; |         run_generate = true; | ||||||
|     } else if (parseInt(chat[chat.length - 1]['swipe_id']) < chat[chat.length - 1]['swipes'].length) { //otherwise, if the id is less than the number of swipes |     } else if (parseInt(chat[chat.length - 1]['swipe_id']) < chat[chat.length - 1]['swipes'].length) { //otherwise, if the id is less than the number of swipes | ||||||
|         chat[chat.length - 1]['mes'] = chat[chat.length - 1]['swipes'][chat[chat.length - 1]['swipe_id']]; //load the last mes box with the latest generation |         chat[chat.length - 1]['mes'] = chat[chat.length - 1]['swipes'][chat[chat.length - 1]['swipe_id']]; //load the last mes box with the latest generation | ||||||
|         chat[chat.length - 1]['send_date'] = chat[chat.length - 1]['swipe_info'][chat[chat.length - 1]['swipe_id']]['send_date']; //update send date |         chat[chat.length - 1]['send_date'] = chat[chat.length - 1]?.swipe_info[chat[chat.length - 1]['swipe_id']]?.send_date || chat[chat.length - 1]['send_date']; //update send date | ||||||
|         run_swipe_right = true; //then prepare to do normal right swipe to show next message |         run_swipe_right = true; //then prepare to do normal right swipe to show next message | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user