Use one callback for setting sysprompt state

1d124ba7709c1c046884d7b52ae03f5133274a9d

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

1 files changed, +11 -14Ignore whitespace
public/scripts/sysprompt.js+11 -14
@@ -86,17 +86,14 @@ function toggleSystemPromptDisabledControls() {
8686 $contentBlock.toggleClass('disabled', !power_user.sysprompt.enabled);
8787}
8888
89-function enableSystemPromptCallback() {
89+/**
90- power_user.sysprompt.enabled = true;
90+ * Sets the system prompt state.
91- $enabled.prop('checked', true);
91+ * @param {boolean} state System prompt state
92- toggleSystemPromptDisabledControls();
92+ * @returns {string} Empty string
93- saveSettingsDebounced();
93+ */
94- return '';
94+function setSystemPromptStateCallback(state) {
95-}
95+ power_user.sysprompt.enabled = state;
96-
96+ $enabled.prop('checked', state);
97-function disableSystemPromptCallback() {
98- power_user.sysprompt.enabled = false;
99- $enabled.prop('checked', false);
10097 toggleSystemPromptDisabledControls();
10198 saveSettingsDebounced();
10299 return '';
@@ -108,7 +105,7 @@ function toggleSystemPromptCallback(_args, state) {
108105 }
109106
110107 const newState = isTrueBoolean(state);
111108 newState ? enableSystemPromptCallbacksetSystemPromptStateCallback(true) : disableSystemPromptCallbacksetSystemPromptStateCallback(false);
112109 return String(power_user.sysprompt.enabled);
113110}
114111
@@ -219,13 +216,13 @@ export function initSystemPrompts() {
219216 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
220217 name: 'sysprompt-on',
221218 aliases: ['sysprompt-enable'],
222- callback: enableSystemPromptCallback,
219+ callback: () => setSystemPromptStateCallback(true),
223220 helpString: 'Enables system prompt.',
224221 }));
225222 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
226223 name: 'sysprompt-off',
227224 aliases: ['sysprompt-disable'],
228- callback: disableSystemPromptCallback,
225+ callback: () => setSystemPromptStateCallback(false),
229226 helpString: 'Disables system prompt',
230227 }));
231228 SlashCommandParser.addCommandObject(SlashCommand.fromProps({