Merge pull request #3154 from SillyTavern/optimize-past-swipes Optimize past swipes
Signed| @@ -4184,7 +4184,7 @@ | ||
| 4184 | 4184 | </label> |
| 4185 | 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 | 4186 | <input id="show_swipe_num_all_messages" type="checkbox" /> |
| 4187 | 4187 | <small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small><i class="fa-solid fa-mobile-screen-button"></i> |
| 4188 | 4188 | </label> |
| 4189 | 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 | 4190 | <input id="hotswapEnabled" type="checkbox" /> |
| @@ -98,7 +98,6 @@ import { | ||
| 98 | 98 | resetMovableStyles, |
| 99 | 99 | forceCharacterEditorTokenize, |
| 100 | 100 | applyPowerUserSettings, |
| 101 | - switchSwipeNumAllMessages, | |
| 102 | 101 | } from './scripts/power-user.js'; |
| 103 | 102 | |
| 104 | 103 | import { |
| @@ -7664,14 +7663,12 @@ export function showSwipeButtons() { | ||
| 7664 | 7663 | //allows for writing individual swipe counters for past messages |
| 7665 | 7664 | const lastSwipeCounter = $('.last_mes .swipes-counter'); |
| 7666 | 7665 | lastSwipeCounter.text(swipeCounterText).show(); |
| 7667 | - | |
| 7668 | - switchSwipeNumAllMessages(); | |
| 7669 | 7666 | } |
| 7670 | 7667 | |
| 7671 | 7668 | export function hideSwipeButtons() { |
| 7672 | 7669 | $('#chat')chatElement.find('.swipe_right').hide(); |
| 7673 | 7670 | $('#chat')chatElement.find('.last_mes .swipes-counter').hide(); |
| 7674 | 7671 | $('#chat')chatElement.find('.swipe_left').hide(); |
| 7675 | 7672 | } |
| 7676 | 7673 | |
| 7677 | 7674 | /** |
| @@ -60,7 +60,6 @@ import { ToolManager } from '../../tool-calling.js'; | ||
| 60 | 60 | export { MODULE_NAME }; |
| 61 | 61 | |
| 62 | 62 | const MODULE_NAME = 'sd'; |
| 63 | -const UPDATE_INTERVAL = 1000; | |
| 64 | 63 | // This is a 1x1 transparent PNG |
| 65 | 64 | const PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; |
| 66 | 65 | const CUSTOM_STOP_EVENT = 'sd_stop_generation'; |
| @@ -3687,8 +3686,6 @@ async function addSDGenButtons() { | ||
| 3687 | 3686 | const button = $('#sd_gen'); |
| 3688 | 3687 | const dropdown = $('#sd_dropdown'); |
| 3689 | 3688 | dropdown.hide(); |
| 3690 | - button.hide(); | |
| 3691 | - messageButton.hide(); | |
| 3692 | 3689 | |
| 3693 | 3690 | let popper = Popper.createPopper(button.get(0), dropdown.get(0), { |
| 3694 | 3691 | placement: 'top', |
| @@ -3770,18 +3767,6 @@ function isValidState() { | ||
| 3770 | 3767 | } |
| 3771 | 3768 | } |
| 3772 | 3769 | |
| 3773 | -async 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 | - | |
| 3784 | -setInterval(moduleWorker, UPDATE_INTERVAL); | |
| 3785 | 3770 | let buttonAbortController = null; |
| 3786 | 3771 | |
| 3787 | 3772 | async function sdMessageButton(e) { |
| @@ -472,9 +472,9 @@ function switchCompactInputArea() { | ||
| 472 | 472 | $('#compact_input_area').prop('checked', power_user.compact_input_area); |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | export function switchSwipeNumAllMessages() { |
| 476 | 476 | $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages); |
| 477 | 477 | $('.mes:not(.last_mes) .swipes-counterbody').csstoggleClass('opacityswipeAllMessages', '').toggle(!!power_user.show_swipe_num_all_messages); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | var originalSliderValues = []; |
| @@ -1040,8 +1040,14 @@ body .panelControlBar { | ||
| 1040 | 1040 | height: var(--swipeCounterHeight); |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | body:not(.swipeAllMessages) .mes:not(.last_mes) .swipes-counter { |
| 1044 | 1044 | opacityvisibility: 0.3hidden; |
| 1045 | +} | |
| 1046 | + | |
| 1047 | +body.swipeAllMessages .mes:not(.last_mes) .swipes-counter { | |
| 1048 | + /* Avoid expensive DOM queries */ | |
| 1049 | + opacity: 0.3 !important; | |
| 1050 | + display: flex !important; | |
| 1045 | 1051 | } |
| 1046 | 1052 | |
| 1047 | 1053 | .swipe_left { |