mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add toggle for persona info notifications
This commit is contained in:
@ -2639,6 +2639,14 @@
|
|||||||
<option value="3" data-i18n="Bottom of Author's Note">Bottom of Author's Note</option>
|
<option value="3" data-i18n="Bottom of Author's Note">Bottom of Author's Note</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="range-block">
|
||||||
|
<label for="persona_show_notifications" class="checkbox_label">
|
||||||
|
<input id="persona_show_notifications" type="checkbox" />
|
||||||
|
<span data-i18n="Show Notifications Show notifications on switching personas">
|
||||||
|
Show notifications on switching personas
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1">
|
||||||
<h4 class="title_restorable">
|
<h4 class="title_restorable">
|
||||||
|
@ -4554,7 +4554,9 @@ export function setUserName(value) {
|
|||||||
name1 = default_user_name;
|
name1 = default_user_name;
|
||||||
console.log(`User name changed to ${name1}`);
|
console.log(`User name changed to ${name1}`);
|
||||||
$("#your_name").val(name1);
|
$("#your_name").val(name1);
|
||||||
|
if (power_user.persona_show_notifications) {
|
||||||
toastr.success(`Your messages will now be sent as ${name1}`, 'Current persona updated');
|
toastr.success(`Your messages will now be sent as ${name1}`, 'Current persona updated');
|
||||||
|
}
|
||||||
saveSettings("change_name");
|
saveSettings("change_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4653,7 +4655,7 @@ function setUserAvatar() {
|
|||||||
const personaName = power_user.personas[user_avatar];
|
const personaName = power_user.personas[user_avatar];
|
||||||
if (personaName && name1 !== personaName) {
|
if (personaName && name1 !== personaName) {
|
||||||
const lockedPersona = chat_metadata['persona'];
|
const lockedPersona = chat_metadata['persona'];
|
||||||
if (lockedPersona && lockedPersona !== user_avatar) {
|
if (lockedPersona && lockedPersona !== user_avatar && power_user.persona_show_notifications) {
|
||||||
toastr.info(
|
toastr.info(
|
||||||
`To permanently set "${personaName}" as the selected persona, unlock and relock it using the "Lock" button. Otherwise, the selection resets upon reloading the chat.`,
|
`To permanently set "${personaName}" as the selected persona, unlock and relock it using the "Lock" button. Otherwise, the selection resets upon reloading the chat.`,
|
||||||
`This chat is locked to a different persona (${power_user.personas[lockedPersona]}).`,
|
`This chat is locked to a different persona (${power_user.personas[lockedPersona]}).`,
|
||||||
@ -4760,7 +4762,9 @@ async function setDefaultPersona() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Removing default persona ${avatarId}`);
|
console.log(`Removing default persona ${avatarId}`);
|
||||||
|
if (power_user.persona_show_notifications) {
|
||||||
toastr.info('This persona will no longer be used by default when you open a new chat.', `Default persona removed`);
|
toastr.info('This persona will no longer be used by default when you open a new chat.', `Default persona removed`);
|
||||||
|
}
|
||||||
delete power_user.default_persona;
|
delete power_user.default_persona;
|
||||||
} else {
|
} else {
|
||||||
const confirm = await callPopup(`<h3>Are you sure you want to set "${personaName}" as the default persona?</h3>
|
const confirm = await callPopup(`<h3>Are you sure you want to set "${personaName}" as the default persona?</h3>
|
||||||
@ -4772,8 +4776,10 @@ async function setDefaultPersona() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
power_user.default_persona = avatarId;
|
power_user.default_persona = avatarId;
|
||||||
|
if (power_user.persona_show_notifications) {
|
||||||
toastr.success('This persona will be used by default when you open a new chat.', `Default persona set to ${personaName}`);
|
toastr.success('This persona will be used by default when you open a new chat.', `Default persona set to ${personaName}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
await getUserAvatars();
|
await getUserAvatars();
|
||||||
@ -4835,18 +4841,22 @@ function lockUserNameToChat() {
|
|||||||
console.log(`Unlocking persona for this chat ${chat_metadata['persona']}`);
|
console.log(`Unlocking persona for this chat ${chat_metadata['persona']}`);
|
||||||
delete chat_metadata['persona'];
|
delete chat_metadata['persona'];
|
||||||
saveMetadata();
|
saveMetadata();
|
||||||
|
if (power_user.persona_show_notifications) {
|
||||||
toastr.info('User persona is now unlocked for this chat. Click the "Lock" again to revert.', 'Persona unlocked');
|
toastr.info('User persona is now unlocked for this chat. Click the "Lock" again to revert.', 'Persona unlocked');
|
||||||
|
}
|
||||||
updateUserLockIcon();
|
updateUserLockIcon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(user_avatar in power_user.personas)) {
|
if (!(user_avatar in power_user.personas)) {
|
||||||
console.log(`Creating a new persona ${user_avatar}`);
|
console.log(`Creating a new persona ${user_avatar}`);
|
||||||
|
if (power_user.persona_show_notifications) {
|
||||||
toastr.info(
|
toastr.info(
|
||||||
'Creating a new persona for currently selected user name and avatar...',
|
'Creating a new persona for currently selected user name and avatar...',
|
||||||
'Persona not set for this avatar',
|
'Persona not set for this avatar',
|
||||||
{ timeOut: 10000, extendedTimeOut: 20000, },
|
{ timeOut: 10000, extendedTimeOut: 20000, },
|
||||||
);
|
);
|
||||||
|
}
|
||||||
power_user.personas[user_avatar] = name1;
|
power_user.personas[user_avatar] = name1;
|
||||||
power_user.persona_descriptions[user_avatar] = { description: '', position: persona_description_positions.BEFORE_CHAR };
|
power_user.persona_descriptions[user_avatar] = { description: '', position: persona_description_positions.BEFORE_CHAR };
|
||||||
}
|
}
|
||||||
@ -4855,7 +4865,9 @@ function lockUserNameToChat() {
|
|||||||
saveMetadata();
|
saveMetadata();
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
console.log(`Locking persona for this chat ${user_avatar}`);
|
console.log(`Locking persona for this chat ${user_avatar}`);
|
||||||
|
if (power_user.persona_show_notifications) {
|
||||||
toastr.success(`User persona is locked to ${name1} in this chat`);
|
toastr.success(`User persona is locked to ${name1} in this chat`);
|
||||||
|
}
|
||||||
updateUserLockIcon();
|
updateUserLockIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import {
|
|||||||
|
|
||||||
import { registerSlashCommand } from "./slash-commands.js";
|
import { registerSlashCommand } from "./slash-commands.js";
|
||||||
|
|
||||||
import { delay, debounce } from "./utils.js";
|
import { delay } from "./utils.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
loadPowerUserSettings,
|
loadPowerUserSettings,
|
||||||
@ -184,6 +184,7 @@ let power_user = {
|
|||||||
|
|
||||||
persona_description: '',
|
persona_description: '',
|
||||||
persona_description_position: persona_description_positions.BEFORE_CHAR,
|
persona_description_position: persona_description_positions.BEFORE_CHAR,
|
||||||
|
persona_show_notifications: true,
|
||||||
|
|
||||||
custom_stopping_strings: '',
|
custom_stopping_strings: '',
|
||||||
fuzzy_search: false,
|
fuzzy_search: false,
|
||||||
@ -678,6 +679,7 @@ function loadPowerUserSettings(settings, data) {
|
|||||||
$('#auto_swipe_blacklist_threshold').val(power_user.auto_swipe_blacklist_threshold);
|
$('#auto_swipe_blacklist_threshold').val(power_user.auto_swipe_blacklist_threshold);
|
||||||
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
|
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
|
||||||
$('#fuzzy_search_checkbox').prop("checked", power_user.fuzzy_search);
|
$('#fuzzy_search_checkbox').prop("checked", power_user.fuzzy_search);
|
||||||
|
$('#persona_show_notifications').prop("checked", power_user.persona_show_notifications);
|
||||||
|
|
||||||
$("#console_log_prompts").prop("checked", power_user.console_log_prompts);
|
$("#console_log_prompts").prop("checked", power_user.console_log_prompts);
|
||||||
$('#auto_fix_generated_markdown').prop("checked", power_user.auto_fix_generated_markdown);
|
$('#auto_fix_generated_markdown').prop("checked", power_user.auto_fix_generated_markdown);
|
||||||
@ -1998,6 +2000,11 @@ $(document).ready(() => {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#persona_show_notifications').on('input', function () {
|
||||||
|
power_user.persona_show_notifications = !!$(this).prop('checked');
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$(window).on('focus', function () {
|
$(window).on('focus', function () {
|
||||||
browser_has_focus = true;
|
browser_has_focus = true;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user