Fix settings not existing before being used
This commit is contained in:
parent
cf2bbe45cd
commit
ae22d44229
|
@ -6,8 +6,8 @@ import { loadSettings } from './js/settings';
|
||||||
import { setupAds } from './js/ads';
|
import { setupAds } from './js/ads';
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
loadDictionary();
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
loadDictionary();
|
||||||
setupListeners();
|
setupListeners();
|
||||||
|
|
||||||
if (hasToken()) {
|
if (hasToken()) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { enableHotKeys, disableHotKeys } from "./hotkeys";
|
||||||
export function loadSettings() {
|
export function loadSettings() {
|
||||||
const storedSettings = window.localStorage.getItem(SETTINGS_KEY);
|
const storedSettings = window.localStorage.getItem(SETTINGS_KEY);
|
||||||
window.settings = storedSettings ? JSON.parse(storedSettings) : cloneObject(DEFAULT_SETTINGS);
|
window.settings = storedSettings ? JSON.parse(storedSettings) : cloneObject(DEFAULT_SETTINGS);
|
||||||
toggleIPAPronunciationFields();
|
toggleIPAPronunciationFields(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveSettings() {
|
export function saveSettings() {
|
||||||
|
@ -67,7 +67,7 @@ export function toggleHotkeysEnabled() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toggleIPAPronunciationFields() {
|
export function toggleIPAPronunciationFields(render = true) {
|
||||||
const ipaButtons = document.querySelectorAll('.ipa-table-button, .ipa-field-help-button'),
|
const ipaButtons = document.querySelectorAll('.ipa-table-button, .ipa-field-help-button'),
|
||||||
ipaFields = document.querySelectorAll('.ipa-field');
|
ipaFields = document.querySelectorAll('.ipa-field');
|
||||||
if (!window.settings.useIPAPronunciationField) {
|
if (!window.settings.useIPAPronunciationField) {
|
||||||
|
@ -85,5 +85,7 @@ export function toggleIPAPronunciationFields() {
|
||||||
field.addEventListener('keypress', usePhondueDigraphs);
|
field.addEventListener('keypress', usePhondueDigraphs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (render) {
|
||||||
renderWords();
|
renderWords();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue