Add checkbox for restoring user input on page refresh

This commit is contained in:
Cohee
2023-11-28 00:29:34 +02:00
parent d263760b25
commit 87707b565f
3 changed files with 31 additions and 1 deletions

View File

@@ -460,6 +460,22 @@ function OpenNavPanels() {
}
}
function restoreUserInput() {
if (!power_user.restore_user_input) {
console.debug('restoreUserInput disabled');
return;
}
const userInput = LoadLocal("userInput");
if (userInput) {
$("#send_textarea").val(userInput).trigger('input');
}
}
function saveUserInput() {
const userInput = String($("#send_textarea").val());
SaveLocal("userInput", userInput);
}
// Make the DIV element draggable:
@@ -895,11 +911,14 @@ export function initRossMods() {
const chatBlock = $('#chat');
const originalScrollBottom = chatBlock[0].scrollHeight - (chatBlock.scrollTop() + chatBlock.outerHeight());
this.style.height = window.getComputedStyle(this).getPropertyValue('min-height');
this.style.height = (this.scrollHeight) + 'px';
this.style.height = this.scrollHeight + 0.1 + 'px';
const newScrollTop = Math.round(chatBlock[0].scrollHeight - (chatBlock.outerHeight() + originalScrollBottom));
chatBlock.scrollTop(newScrollTop);
saveUserInput();
});
restoreUserInput();
//Regenerate if user swipes on the last mesage in chat
document.addEventListener('swiped-left', function (e) {