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