Make user input saving account-specific
| @@ -41,6 +41,7 @@ import { debounce_timeout } from './constants.js'; | ||
| 41 | 41 | |
| 42 | 42 | import { Popup } from './popup.js'; |
| 43 | 43 | import { accountStorage } from './util/AccountStorage.js'; |
| 44 | +import { getCurrentUserHandle } from './user.js'; | |
| 44 | 45 | |
| 45 | 46 | var RPanelPin = document.getElementById('rm_button_panel_pin'); |
| 46 | 47 | var LPanelPin = document.getElementById('lm_button_panel_pin'); |
| @@ -428,13 +429,15 @@ function OpenNavPanels() { | ||
| 428 | 429 | } |
| 429 | 430 | } |
| 430 | 431 | |
| 432 | +const getUserInputKey = () => getCurrentUserHandle() + '_userInput'; | |
| 433 | + | |
| 431 | 434 | function restoreUserInput() { |
| 432 | 435 | if (!power_user.restore_user_input) { |
| 433 | 436 | console.debug('restoreUserInput disabled'); |
| 434 | 437 | return; |
| 435 | 438 | } |
| 436 | 439 | |
| 437 | 440 | const userInput = localStorage.getItem('userInput'getUserInputKey()); |
| 438 | 441 | if (userInput) { |
| 439 | 442 | $('#send_textarea').val(userInput)[0].dispatchEvent(new Event('input', { bubbles: true })); |
| 440 | 443 | } |
| @@ -442,7 +445,7 @@ function restoreUserInput() { | ||
| 442 | 445 | |
| 443 | 446 | function saveUserInput() { |
| 444 | 447 | const userInput = String($('#send_textarea').val()); |
| 445 | 448 | localStorage.setItem('userInput'getUserInputKey(), userInput); |
| 446 | 449 | console.debug('User Input -- ', userInput); |
| 447 | 450 | } |
| 448 | 451 | const saveUserInputDebounced = debounce(saveUserInput); |
| @@ -44,6 +44,14 @@ export function isAdmin() { | ||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | + * Gets the handle string of the current user. | |
| 48 | + * @returns {string} User handle | |
| 49 | + */ | |
| 50 | +export function getCurrentUserHandle() { | |
| 51 | + return currentUser?.handle || 'default-user'; | |
| 52 | +} | |
| 53 | + | |
| 54 | +/** | |
| 47 | 55 | * Get the current user. |
| 48 | 56 | * @returns {Promise<void>} |
| 49 | 57 | */ |