mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Use one callback for setting sysprompt state
This commit is contained in:
@@ -86,17 +86,14 @@ function toggleSystemPromptDisabledControls() {
|
|||||||
$contentBlock.toggleClass('disabled', !power_user.sysprompt.enabled);
|
$contentBlock.toggleClass('disabled', !power_user.sysprompt.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableSystemPromptCallback() {
|
/**
|
||||||
power_user.sysprompt.enabled = true;
|
* Sets the system prompt state.
|
||||||
$enabled.prop('checked', true);
|
* @param {boolean} state System prompt state
|
||||||
toggleSystemPromptDisabledControls();
|
* @returns {string} Empty string
|
||||||
saveSettingsDebounced();
|
*/
|
||||||
return '';
|
function setSystemPromptStateCallback(state) {
|
||||||
}
|
power_user.sysprompt.enabled = state;
|
||||||
|
$enabled.prop('checked', state);
|
||||||
function disableSystemPromptCallback() {
|
|
||||||
power_user.sysprompt.enabled = false;
|
|
||||||
$enabled.prop('checked', false);
|
|
||||||
toggleSystemPromptDisabledControls();
|
toggleSystemPromptDisabledControls();
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
return '';
|
return '';
|
||||||
@@ -108,7 +105,7 @@ function toggleSystemPromptCallback(_args, state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newState = isTrueBoolean(state);
|
const newState = isTrueBoolean(state);
|
||||||
newState ? enableSystemPromptCallback() : disableSystemPromptCallback();
|
newState ? setSystemPromptStateCallback(true) : setSystemPromptStateCallback(false);
|
||||||
return String(power_user.sysprompt.enabled);
|
return String(power_user.sysprompt.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,13 +216,13 @@ export function initSystemPrompts() {
|
|||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'sysprompt-on',
|
name: 'sysprompt-on',
|
||||||
aliases: ['sysprompt-enable'],
|
aliases: ['sysprompt-enable'],
|
||||||
callback: enableSystemPromptCallback,
|
callback: () => setSystemPromptStateCallback(true),
|
||||||
helpString: 'Enables system prompt.',
|
helpString: 'Enables system prompt.',
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'sysprompt-off',
|
name: 'sysprompt-off',
|
||||||
aliases: ['sysprompt-disable'],
|
aliases: ['sysprompt-disable'],
|
||||||
callback: disableSystemPromptCallback,
|
callback: () => setSystemPromptStateCallback(false),
|
||||||
helpString: 'Disables system prompt',
|
helpString: 'Disables system prompt',
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
|
Reference in New Issue
Block a user