Migrate QR editor preferences to accountStorage

This commit is contained in:
Cohee 2025-02-12 11:29:27 +02:00
parent 340c03cedf
commit 34d17a4fcb
2 changed files with 13 additions and 8 deletions

View File

@ -10,6 +10,7 @@ import { SlashCommandExecutor } from '../../../slash-commands/SlashCommandExecut
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js'; import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
import { SlashCommandParserError } from '../../../slash-commands/SlashCommandParserError.js'; import { SlashCommandParserError } from '../../../slash-commands/SlashCommandParserError.js';
import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js'; import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js';
import { accountStorage } from '../../../util/AccountStorage.js';
import { debounce, delay, getSortableDelay, showFontAwesomePicker } from '../../../utils.js'; import { debounce, delay, getSortableDelay, showFontAwesomePicker } from '../../../utils.js';
import { log, quickReplyApi, warn } from '../index.js'; import { log, quickReplyApi, warn } from '../index.js';
import { QuickReplyContextLink } from './QuickReplyContextLink.js'; import { QuickReplyContextLink } from './QuickReplyContextLink.js';
@ -544,9 +545,9 @@ export class QuickReply {
this.editorSyntax = messageSyntaxInner; this.editorSyntax = messageSyntaxInner;
/**@type {HTMLInputElement}*/ /**@type {HTMLInputElement}*/
const wrap = dom.querySelector('#qr--modal-wrap'); const wrap = dom.querySelector('#qr--modal-wrap');
wrap.checked = JSON.parse(localStorage.getItem('qr--wrap') ?? 'false'); wrap.checked = JSON.parse(accountStorage.getItem('qr--wrap') ?? 'false');
wrap.addEventListener('click', () => { wrap.addEventListener('click', () => {
localStorage.setItem('qr--wrap', JSON.stringify(wrap.checked)); accountStorage.setItem('qr--wrap', JSON.stringify(wrap.checked));
updateWrap(); updateWrap();
}); });
const updateWrap = () => { const updateWrap = () => {
@ -594,27 +595,27 @@ export class QuickReply {
}; };
/**@type {HTMLInputElement}*/ /**@type {HTMLInputElement}*/
const tabSize = dom.querySelector('#qr--modal-tabSize'); const tabSize = dom.querySelector('#qr--modal-tabSize');
tabSize.value = JSON.parse(localStorage.getItem('qr--tabSize') ?? '4'); tabSize.value = JSON.parse(accountStorage.getItem('qr--tabSize') ?? '4');
const updateTabSize = () => { const updateTabSize = () => {
message.style.tabSize = tabSize.value; message.style.tabSize = tabSize.value;
messageSyntaxInner.style.tabSize = tabSize.value; messageSyntaxInner.style.tabSize = tabSize.value;
updateScrollDebounced(); updateScrollDebounced();
}; };
tabSize.addEventListener('change', () => { tabSize.addEventListener('change', () => {
localStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value))); accountStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value)));
updateTabSize(); updateTabSize();
}); });
/**@type {HTMLInputElement}*/ /**@type {HTMLInputElement}*/
const executeShortcut = dom.querySelector('#qr--modal-executeShortcut'); const executeShortcut = dom.querySelector('#qr--modal-executeShortcut');
executeShortcut.checked = JSON.parse(localStorage.getItem('qr--executeShortcut') ?? 'true'); executeShortcut.checked = JSON.parse(accountStorage.getItem('qr--executeShortcut') ?? 'true');
executeShortcut.addEventListener('click', () => { executeShortcut.addEventListener('click', () => {
localStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked)); accountStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked));
}); });
/**@type {HTMLInputElement}*/ /**@type {HTMLInputElement}*/
const syntax = dom.querySelector('#qr--modal-syntax'); const syntax = dom.querySelector('#qr--modal-syntax');
syntax.checked = JSON.parse(localStorage.getItem('qr--syntax') ?? 'true'); syntax.checked = JSON.parse(accountStorage.getItem('qr--syntax') ?? 'true');
syntax.addEventListener('click', () => { syntax.addEventListener('click', () => {
localStorage.setItem('qr--syntax', JSON.stringify(syntax.checked)); accountStorage.setItem('qr--syntax', JSON.stringify(syntax.checked));
updateSyntaxEnabled(); updateSyntaxEnabled();
}); });
if (navigator.keyboard) { if (navigator.keyboard) {

View File

@ -21,6 +21,10 @@ const MIGRATABLE_KEYS = [
/^Personas_PerPage$/, /^Personas_PerPage$/,
/^Personas_GridView$/, /^Personas_GridView$/,
/^Proxy_SkipConfirm_/, /^Proxy_SkipConfirm_/,
/^qr--executeShortcut$/,
/^qr--syntax$/,
/^qr--tabSize$/,
/^qr--wrap$/,
/^RegenerateWithCtrlEnter$/, /^RegenerateWithCtrlEnter$/,
/^SelectedNavTab$/, /^SelectedNavTab$/,
/^sendAsNamelessWarningShown$/, /^sendAsNamelessWarningShown$/,