Fix settings not existing before being used

This commit is contained in:
Robbie Antenesse 2019-06-05 17:28:49 -06:00
parent cf2bbe45cd
commit ae22d44229
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'; import { setupAds } from './js/ads';
function initialize() { function initialize() {
loadDictionary();
loadSettings(); loadSettings();
loadDictionary();
setupListeners(); setupListeners();
if (hasToken()) { if (hasToken()) {

View File

@ -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();
} }
}