async for resetScrollHeight, slightly faster WI/AF panel loads

This commit is contained in:
RossAscends
2024-08-05 12:03:46 +09:00
parent c13ca77bd9
commit 64e716bb62
7 changed files with 42 additions and 38 deletions

View File

@@ -719,29 +719,29 @@ function onChatChanged() {
adjustElementScrollHeight();
}
function adjustElementScrollHeight() {
async function adjustElementScrollHeight() {
if (!$('.sd_settings').is(':visible')) {
return;
}
resetScrollHeight($('#sd_prompt_prefix'));
resetScrollHeight($('#sd_negative_prompt'));
resetScrollHeight($('#sd_character_prompt'));
resetScrollHeight($('#sd_character_negative_prompt'));
await resetScrollHeight($('#sd_prompt_prefix'));
await resetScrollHeight($('#sd_negative_prompt'));
await resetScrollHeight($('#sd_character_prompt'));
await resetScrollHeight($('#sd_character_negative_prompt'));
}
function onCharacterPromptInput() {
async function onCharacterPromptInput() {
const key = getCharaFilename(this_chid);
extension_settings.sd.character_prompts[key] = $('#sd_character_prompt').val();
resetScrollHeight($(this));
await resetScrollHeight($(this));
saveSettingsDebounced();
writePromptFieldsDebounced(this_chid);
}
function onCharacterNegativePromptInput() {
async function onCharacterNegativePromptInput() {
const key = getCharaFilename(this_chid);
extension_settings.sd.character_negative_prompts[key] = $('#sd_character_negative_prompt').val();
resetScrollHeight($(this));
await resetScrollHeight($(this));
saveSettingsDebounced();
writePromptFieldsDebounced(this_chid);
}
@@ -850,15 +850,15 @@ function onStepsInput() {
saveSettingsDebounced();
}
function onPromptPrefixInput() {
async function onPromptPrefixInput() {
extension_settings.sd.prompt_prefix = $('#sd_prompt_prefix').val();
resetScrollHeight($(this));
await resetScrollHeight($(this));
saveSettingsDebounced();
}
function onNegativePromptInput() {
async function onNegativePromptInput() {
extension_settings.sd.negative_prompt = $('#sd_negative_prompt').val();
resetScrollHeight($(this));
await resetScrollHeight($(this));
saveSettingsDebounced();
}

View File

@@ -59,8 +59,8 @@ async function doTokenCounter() {
$('#tokenized_chunks_display').text('—');
}
resetScrollHeight($('#token_counter_textarea'));
resetScrollHeight($('#token_counter_ids'));
await resetScrollHeight($('#token_counter_textarea'));
await resetScrollHeight($('#token_counter_ids'));
}, debounce_timeout.relaxed);
dialog.find('#token_counter_textarea').on('input', () => countDebounced());
@@ -134,7 +134,8 @@ jQuery(() => {
</div>`;
$('#token_counter_wand_container').append(buttonHtml);
$('#token_counter').on('click', doTokenCounter);
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'count',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'count',
callback: async () => String(await doCount()),
returns: 'number of tokens',
helpString: 'Counts the number of tokens in the current chat.',