mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Make user input saving account-specific
This commit is contained in:
@ -41,6 +41,7 @@ import { debounce_timeout } from './constants.js';
|
||||
|
||||
import { Popup } from './popup.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
import { getCurrentUserHandle } from './user.js';
|
||||
|
||||
var RPanelPin = document.getElementById('rm_button_panel_pin');
|
||||
var LPanelPin = document.getElementById('lm_button_panel_pin');
|
||||
@ -428,13 +429,15 @@ function OpenNavPanels() {
|
||||
}
|
||||
}
|
||||
|
||||
const getUserInputKey = () => getCurrentUserHandle() + '_userInput';
|
||||
|
||||
function restoreUserInput() {
|
||||
if (!power_user.restore_user_input) {
|
||||
console.debug('restoreUserInput disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
const userInput = localStorage.getItem('userInput');
|
||||
const userInput = localStorage.getItem(getUserInputKey());
|
||||
if (userInput) {
|
||||
$('#send_textarea').val(userInput)[0].dispatchEvent(new Event('input', { bubbles: true }));
|
||||
}
|
||||
@ -442,7 +445,7 @@ function restoreUserInput() {
|
||||
|
||||
function saveUserInput() {
|
||||
const userInput = String($('#send_textarea').val());
|
||||
localStorage.setItem('userInput', userInput);
|
||||
localStorage.setItem(getUserInputKey(), userInput);
|
||||
console.debug('User Input -- ', userInput);
|
||||
}
|
||||
const saveUserInputDebounced = debounce(saveUserInput);
|
||||
|
@ -43,6 +43,14 @@ export function isAdmin() {
|
||||
return Boolean(currentUser.admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handle string of the current user.
|
||||
* @returns {string} User handle
|
||||
*/
|
||||
export function getCurrentUserHandle() {
|
||||
return currentUser?.handle || 'default-user';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current user.
|
||||
* @returns {Promise<void>}
|
||||
|
Reference in New Issue
Block a user