Merge pull request #3154 from SillyTavern/optimize-past-swipes Optimize past swipes

3ed095bb0e59d2ca91cf6d576f67e44c4dd87efa

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
5 files changed, +14 -26Ignore whitespace
public/index.html+1 -1
@@ -4184,7 +4184,7 @@
4184 </label>4184 </label>
4185 <label for="show_swipe_num_all_messages" class="checkbox_label" title="Display swipe numbers for all messages, not just the last." data-i18n="[title]Display swipe numbers for all messages, not just the last.">4185 <label for="show_swipe_num_all_messages" class="checkbox_label" title="Display swipe numbers for all messages, not just the last." data-i18n="[title]Display swipe numbers for all messages, not just the last.">
4186 <input id="show_swipe_num_all_messages" type="checkbox" />4186 <input id="show_swipe_num_all_messages" type="checkbox" />
4187 <small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small><i class="fa-solid fa-mobile-screen-button"></i>4187 <small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small>
4188 </label>4188 </label>
4189 <label for="hotswapEnabled" class="checkbox_label" title="In the Character Management panel, show quick selection buttons for favorited characters." data-i18n="[title]In the Character Management panel, show quick selection buttons for favorited characters">4189 <label for="hotswapEnabled" class="checkbox_label" title="In the Character Management panel, show quick selection buttons for favorited characters." data-i18n="[title]In the Character Management panel, show quick selection buttons for favorited characters">
4190 <input id="hotswapEnabled" type="checkbox" />4190 <input id="hotswapEnabled" type="checkbox" />
public/script.js+3 -6
@@ -98,7 +98,6 @@ import {
98 resetMovableStyles,98 resetMovableStyles,
99 forceCharacterEditorTokenize,99 forceCharacterEditorTokenize,
100 applyPowerUserSettings,100 applyPowerUserSettings,
101 switchSwipeNumAllMessages,
102} from './scripts/power-user.js';101} from './scripts/power-user.js';
103102
104import {103import {
@@ -7664,14 +7663,12 @@ export function showSwipeButtons() {
7664 //allows for writing individual swipe counters for past messages7663 //allows for writing individual swipe counters for past messages
7665 const lastSwipeCounter = $('.last_mes .swipes-counter');7664 const lastSwipeCounter = $('.last_mes .swipes-counter');
7666 lastSwipeCounter.text(swipeCounterText).show();7665 lastSwipeCounter.text(swipeCounterText).show();
7667
7668 switchSwipeNumAllMessages();
7669}7666}
76707667
7671export function hideSwipeButtons() {7668export function hideSwipeButtons() {
7672 $('#chat').find('.swipe_right').hide();7669 chatElement.find('.swipe_right').hide();
7673 $('#chat').find('.last_mes .swipes-counter').hide();7670 chatElement.find('.last_mes .swipes-counter').hide();
7674 $('#chat').find('.swipe_left').hide();7671 chatElement.find('.swipe_left').hide();
7675}7672}
76767673
7677/**7674/**
public/scripts/extensions/stable-diffusion/index.js+0 -15
@@ -60,7 +60,6 @@ import { ToolManager } from '../../tool-calling.js';
60export { MODULE_NAME };60export { MODULE_NAME };
6161
62const MODULE_NAME = 'sd';62const MODULE_NAME = 'sd';
63const UPDATE_INTERVAL = 1000;
64// This is a 1x1 transparent PNG63// This is a 1x1 transparent PNG
65const PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';64const PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
66const CUSTOM_STOP_EVENT = 'sd_stop_generation';65const CUSTOM_STOP_EVENT = 'sd_stop_generation';
@@ -3687,8 +3686,6 @@ async function addSDGenButtons() {
3687 const button = $('#sd_gen');3686 const button = $('#sd_gen');
3688 const dropdown = $('#sd_dropdown');3687 const dropdown = $('#sd_dropdown');
3689 dropdown.hide();3688 dropdown.hide();
3690 button.hide();
3691 messageButton.hide();
36923689
3693 let popper = Popper.createPopper(button.get(0), dropdown.get(0), {3690 let popper = Popper.createPopper(button.get(0), dropdown.get(0), {
3694 placement: 'top',3691 placement: 'top',
@@ -3770,18 +3767,6 @@ function isValidState() {
3770 }3767 }
3771}3768}
37723769
3773async function moduleWorker() {
3774 if (isValidState()) {
3775 $('#sd_gen').show();
3776 $('.sd_message_gen').show();
3777 }
3778 else {
3779 $('#sd_gen').hide();
3780 $('.sd_message_gen').hide();
3781 }
3782}
3783
3784setInterval(moduleWorker, UPDATE_INTERVAL);
3785let buttonAbortController = null;3770let buttonAbortController = null;
37863771
3787async function sdMessageButton(e) {3772async function sdMessageButton(e) {
public/scripts/power-user.js+2 -2
@@ -472,9 +472,9 @@ function switchCompactInputArea() {
472 $('#compact_input_area').prop('checked', power_user.compact_input_area);472 $('#compact_input_area').prop('checked', power_user.compact_input_area);
473}473}
474474
475export function switchSwipeNumAllMessages() {475function switchSwipeNumAllMessages() {
476 $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);476 $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
477 $('.mes:not(.last_mes) .swipes-counter').css('opacity', '').toggle(power_user.show_swipe_num_all_messages);477 $('body').toggleClass('swipeAllMessages', !!power_user.show_swipe_num_all_messages);
478}478}
479479
480var originalSliderValues = [];480var originalSliderValues = [];
public/style.css+8 -2
@@ -1040,8 +1040,14 @@ body .panelControlBar {
1040 height: var(--swipeCounterHeight);1040 height: var(--swipeCounterHeight);
1041}1041}
10421042
1043.mes:not(.last_mes) .swipes-counter {1043body:not(.swipeAllMessages) .mes:not(.last_mes) .swipes-counter {
1044 opacity: 0.3;1044 visibility: hidden;
1045}
1046
1047body.swipeAllMessages .mes:not(.last_mes) .swipes-counter {
1048 /* Avoid expensive DOM queries */
1049 opacity: 0.3 !important;
1050 display: flex !important;
1045}1051}
10461052
1047.swipe_left {1053.swipe_left {