Fix settings not existing before being used

This commit is contained in:
Robbie Antenesse 2019-06-05 17:28:49 -06:00 committed by Robbie Antenesse
parent 881cd9cb2e
commit 64903fc544
2 changed files with 6 additions and 4 deletions

View File

@ -6,8 +6,8 @@ import { loadSettings } from './js/settings';
import { setupAds } from './js/ads';
function initialize() {
loadDictionary();
loadSettings();
loadDictionary();
setupListeners();
if (hasToken()) {

View File

@ -8,7 +8,7 @@ import { enableHotKeys, disableHotKeys } from "./hotkeys";
export function loadSettings() {
const storedSettings = window.localStorage.getItem(SETTINGS_KEY);
window.settings = storedSettings ? JSON.parse(storedSettings) : cloneObject(DEFAULT_SETTINGS);
toggleIPAPronunciationFields();
toggleIPAPronunciationFields(false);
}
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'),
ipaFields = document.querySelectorAll('.ipa-field');
if (!window.settings.useIPAPronunciationField) {
@ -85,5 +85,7 @@ export function toggleIPAPronunciationFields() {
field.addEventListener('keypress', usePhondueDigraphs);
});
}
renderWords();
if (render) {
renderWords();
}
}