Disable swipe arrows on SD gens. Disable TTS play on switching character or reloading the page

This commit is contained in:
SillyLossy
2023-05-07 19:20:21 +03:00
parent abb4ca95b3
commit 40e73d1c94
2 changed files with 13 additions and 4 deletions

View File

@@ -1120,8 +1120,6 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
const newMessage = $(`#chat [mesid="${count_view_mes}"]`); const newMessage = $(`#chat [mesid="${count_view_mes}"]`);
newMessage.data("isSystem", isSystem); newMessage.data("isSystem", isSystem);
appendImageToMessage(mes, newMessage);
if (isSystem) { if (isSystem) {
newMessage.find(".mes_edit").hide(); newMessage.find(".mes_edit").hide();
} }
@@ -1134,6 +1132,7 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
if (type === 'swipe') { if (type === 'swipe') {
$("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').html(''); $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').html('');
$("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').append(messageText); $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').append(messageText);
appendImageToMessage(mes, $("#chat").find(`[mesid="${count_view_mes - 1}"]`));
$("#chat").find(`[mesid="${count_view_mes - 1}"]`).attr('title', title); $("#chat").find(`[mesid="${count_view_mes - 1}"]`).attr('title', title);
if (mes.swipe_id == mes.swipes.length - 1) { if (mes.swipe_id == mes.swipes.length - 1) {
@@ -1144,6 +1143,7 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
} }
} else { } else {
$("#chat").find(`[mesid="${count_view_mes}"]`).find('.mes_text').append(messageText); $("#chat").find(`[mesid="${count_view_mes}"]`).find('.mes_text').append(messageText);
appendImageToMessage(mes, newMessage);
hideSwipeButtons(); hideSwipeButtons();
count_view_mes++; count_view_mes++;
} }
@@ -3773,6 +3773,7 @@ function showSwipeButtons() {
!swipes || !swipes ||
$('.mes:last').attr('mesid') <= 0 || $('.mes:last').attr('mesid') <= 0 ||
chat[chat.length - 1].is_user || chat[chat.length - 1].is_user ||
chat[chat.length - 1].extra?.image ||
count_view_mes <= 1 || count_view_mes <= 1 ||
(selected_group && is_group_generating) (selected_group && is_group_generating)
) { return; } ) { return; }
@@ -3894,7 +3895,11 @@ function isHordeGenerationNotAllowed() {
return false; return false;
} }
export function cancelTtsPlay() {
if (speechSynthesis) {
speechSynthesis.cancel();
}
}
window["SillyTavern"].getContext = function () { window["SillyTavern"].getContext = function () {
return { return {
@@ -4305,6 +4310,7 @@ $(document).ready(function () {
if (this_chid !== $(this).attr("chid")) { if (this_chid !== $(this).attr("chid")) {
//if clicked on a different character from what was currently selected //if clicked on a different character from what was currently selected
if (!is_send_press) { if (!is_send_press) {
cancelTtsPlay();
resetSelectedGroup(); resetSelectedGroup();
this_edit_mes_id = undefined; this_edit_mes_id = undefined;
selected_button = "character_edit"; selected_button = "character_edit";
@@ -5764,7 +5770,8 @@ $(document).ready(function () {
$('.code-copied').css({ 'display': 'none' }); $('.code-copied').css({ 'display': 'none' });
}); });
$(document).on('beforeunload', () => { $(window).on('beforeunload', () => {
cancelTtsPlay();
if (streamingProcessor) { if (streamingProcessor) {
console.log('Page reloaded. Aborting streaming...'); console.log('Page reloaded. Aborting streaming...');
streamingProcessor.abortController.abort(); streamingProcessor.abortController.abort();

View File

@@ -45,6 +45,7 @@ import {
setMenuType, setMenuType,
menu_type, menu_type,
select_selected_character, select_selected_character,
cancelTtsPlay,
} from "../script.js"; } from "../script.js";
import { appendTagToList, createTagMapFromList, getTagsList, applyTagsOnCharacterSelect } from './tags.js'; import { appendTagToList, createTagMapFromList, getTagsList, applyTagsOnCharacterSelect } from './tags.js';
@@ -1006,6 +1007,7 @@ async function selectGroup() {
if (!is_send_press && !is_group_generating) { if (!is_send_press && !is_group_generating) {
if (selected_group !== groupId) { if (selected_group !== groupId) {
cancelTtsPlay();
selected_group = groupId; selected_group = groupId;
setCharacterId(undefined); setCharacterId(undefined);
setCharacterName(''); setCharacterName('');