mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix /lockbg and /unlockbg commands
This commit is contained in:
@ -96,8 +96,13 @@ function highlightLockedBackground() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locks the background for the current chat
|
||||||
|
* @param {Event} e Click event
|
||||||
|
* @returns {string} Empty string
|
||||||
|
*/
|
||||||
function onLockBackgroundClick(e) {
|
function onLockBackgroundClick(e) {
|
||||||
e.stopPropagation();
|
e?.stopPropagation();
|
||||||
|
|
||||||
const chatName = getCurrentChatId();
|
const chatName = getCurrentChatId();
|
||||||
|
|
||||||
@ -114,8 +119,13 @@ function onLockBackgroundClick(e) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locks the background for the current chat
|
||||||
|
* @param {Event} e Click event
|
||||||
|
* @returns {string} Empty string
|
||||||
|
*/
|
||||||
function onUnlockBackgroundClick(e) {
|
function onUnlockBackgroundClick(e) {
|
||||||
e.stopPropagation();
|
e?.stopPropagation();
|
||||||
removeBackgroundMetadata();
|
removeBackgroundMetadata();
|
||||||
unsetCustomBackground();
|
unsetCustomBackground();
|
||||||
highlightLockedBackground();
|
highlightLockedBackground();
|
||||||
@ -513,12 +523,12 @@ export function initBackgrounds() {
|
|||||||
$('#add_bg_button').on('change', onBackgroundUploadSelected);
|
$('#add_bg_button').on('change', onBackgroundUploadSelected);
|
||||||
$('#bg-filter').on('input', onBackgroundFilterInput);
|
$('#bg-filter').on('input', onBackgroundFilterInput);
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'lockbg',
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'lockbg',
|
||||||
callback: onLockBackgroundClick,
|
callback: () => onLockBackgroundClick(new CustomEvent('click')),
|
||||||
aliases: ['bglock'],
|
aliases: ['bglock'],
|
||||||
helpString: 'Locks a background for the currently selected chat',
|
helpString: 'Locks a background for the currently selected chat',
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'unlockbg',
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'unlockbg',
|
||||||
callback: onUnlockBackgroundClick,
|
callback: () => onUnlockBackgroundClick(new CustomEvent('click')),
|
||||||
aliases: ['bgunlock'],
|
aliases: ['bgunlock'],
|
||||||
helpString: 'Unlocks a background for the currently selected chat',
|
helpString: 'Unlocks a background for the currently selected chat',
|
||||||
}));
|
}));
|
||||||
|
Reference in New Issue
Block a user