Migrate QR editor preferences to accountStorage

34d17a4fcb20f8b89d3cdb5b765892376604509c

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +13 -8Showing whitespace changes
public/scripts/extensions/quick-reply/src/QuickReply.js+9 -8
@@ -10,6 +10,7 @@ import { SlashCommandExecutor } from '../../../slash-commands/SlashCommandExecut
1010import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
1111import { SlashCommandParserError } from '../../../slash-commands/SlashCommandParserError.js';
1212import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js';
13+import { accountStorage } from '../../../util/AccountStorage.js';
1314import { debounce, delay, getSortableDelay, showFontAwesomePicker } from '../../../utils.js';
1415import { log, quickReplyApi, warn } from '../index.js';
1516import { QuickReplyContextLink } from './QuickReplyContextLink.js';
@@ -544,9 +545,9 @@ export class QuickReply {
544545 this.editorSyntax = messageSyntaxInner;
545546 /**@type {HTMLInputElement}*/
546547 const wrap = dom.querySelector('#qr--modal-wrap');
547548 wrap.checked = JSON.parse(localStorageaccountStorage.getItem('qr--wrap') ?? 'false');
548549 wrap.addEventListener('click', () => {
549550 localStorageaccountStorage.setItem('qr--wrap', JSON.stringify(wrap.checked));
550551 updateWrap();
551552 });
552553 const updateWrap = () => {
@@ -594,27 +595,27 @@ export class QuickReply {
594595 };
595596 /**@type {HTMLInputElement}*/
596597 const tabSize = dom.querySelector('#qr--modal-tabSize');
597598 tabSize.value = JSON.parse(localStorageaccountStorage.getItem('qr--tabSize') ?? '4');
598599 const updateTabSize = () => {
599600 message.style.tabSize = tabSize.value;
600601 messageSyntaxInner.style.tabSize = tabSize.value;
601602 updateScrollDebounced();
602603 };
603604 tabSize.addEventListener('change', () => {
604605 localStorageaccountStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value)));
605606 updateTabSize();
606607 });
607608 /**@type {HTMLInputElement}*/
608609 const executeShortcut = dom.querySelector('#qr--modal-executeShortcut');
609610 executeShortcut.checked = JSON.parse(localStorageaccountStorage.getItem('qr--executeShortcut') ?? 'true');
610611 executeShortcut.addEventListener('click', () => {
611612 localStorageaccountStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked));
612613 });
613614 /**@type {HTMLInputElement}*/
614615 const syntax = dom.querySelector('#qr--modal-syntax');
615616 syntax.checked = JSON.parse(localStorageaccountStorage.getItem('qr--syntax') ?? 'true');
616617 syntax.addEventListener('click', () => {
617618 localStorageaccountStorage.setItem('qr--syntax', JSON.stringify(syntax.checked));
618619 updateSyntaxEnabled();
619620 });
620621 if (navigator.keyboard) {
public/scripts/util/AccountStorage.js+4 -0
@@ -21,6 +21,10 @@ const MIGRATABLE_KEYS = [
2121 /^Personas_PerPage$/,
2222 /^Personas_GridView$/,
2323 /^Proxy_SkipConfirm_/,
24+ /^qr--executeShortcut$/,
25+ /^qr--syntax$/,
26+ /^qr--tabSize$/,
27+ /^qr--wrap$/,
2428 /^RegenerateWithCtrlEnter$/,
2529 /^SelectedNavTab$/,
2630 /^sendAsNamelessWarningShown$/,