Sync user name to chat option

This commit is contained in:
SillyLossy
2023-05-28 23:17:49 +03:00
parent b74939bf65
commit 5efd55d343
2 changed files with 20 additions and 0 deletions

View File

@ -1866,6 +1866,8 @@
<input id="your_name" name="your_name" placeholder="Enter your name" class="text_pole wide100p" maxlength="50" value="" autocomplete="off"> <input id="your_name" name="your_name" placeholder="Enter your name" class="text_pole wide100p" maxlength="50" value="" autocomplete="off">
<div id="your_name_button" class="menu_button fa-solid fa-check" title="Click to set a new User Name"> <div id="your_name_button" class="menu_button fa-solid fa-check" title="Click to set a new User Name">
</div> </div>
<div id="sync_name_button" class="menu_button fa-solid fa-sync" title="Click to set user name for all messages">
</div>
</div> </div>
</div> </div>
<div name="AvatarSelector"> <div name="AvatarSelector">

View File

@ -6440,9 +6440,27 @@ $(document).ready(function () {
name1 = $("#your_name").val(); name1 = $("#your_name").val();
if (name1 === undefined || name1 == "") name1 = default_user_name; if (name1 === undefined || name1 == "") name1 = default_user_name;
console.log(name1); console.log(name1);
toastr.success(`Your messages will now be sent as ${name1}`, 'User Name updated');
saveSettings("change_name"); saveSettings("change_name");
} }
}); });
$('#sync_name_button').on('click', async function () {
const confirmation = await callPopup(`<h3>Are you sure?</h3>All user-sent messages in this chat will be attributed to ${name1}.`, 'confirm');
if (!confirmation) {
return;
}
for (const mes of chat) {
if (mes.is_user) {
mes.name = name1;
}
}
await saveChatConditional();
await reloadCurrentChat();
});
//Select chat //Select chat
$("#api_button_novel").on('click', async function (e) { $("#api_button_novel").on('click', async function (e) {