Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Falsy setting values now correctly initialize. #408

Merged
merged 5 commits into from
Apr 23, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions extension/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ function initializeConfigFromCloudOrLocalStorageOrDefaults(cloudStorage) {
* @param {boolean | number | string} defaultValue
*/
function initConfig(key, defaultValue) {
let currentValue =
cloudStorage[key] || normalizeStringValue(localStorage[key]);
const cloudValue = cloudStorage[key];
SamDunlap marked this conversation as resolved.
Show resolved Hide resolved
const localValue = normalizeStringValue(localStorage[key]);
let currentValue = localValue;
if (localValue === undefined) {
currentValue = cloudValue;
}
if (currentValue === undefined) {
currentValue = defaultValue;
}
Expand Down Expand Up @@ -124,7 +128,7 @@ function initializeConfigFromCloudOrLocalStorageOrDefaults(cloudStorage) {
const kanjiInfoLabelList = RcxDict.prototype.kanjiInfoLabelList;
for (i = 0; i < kanjiInfoLabelList.length; i += 2) {
const kanjiInfoKey = kanjiInfoLabelList[i];
if (cloudStorage.kanjiInfo && cloudStorage.kanjiInfo[kanjiInfoKey]) {
if (cloudStorage.kanjiInfo) {
SamDunlap marked this conversation as resolved.
Show resolved Hide resolved
rcxMain.config.kanjiInfo[kanjiInfoKey] =
cloudStorage.kanjiInfo[kanjiInfoKey];
} else if (localStorage[kanjiInfoKey]) {
Expand All @@ -137,10 +141,7 @@ function initializeConfigFromCloudOrLocalStorageOrDefaults(cloudStorage) {
}
}

/**
* Saves options to Google Chrome Cloud storage
* https://developer.chrome.com/storage
*/
/* Saves options to Google Chrome Cloud storage https://developer.chrome.com/storage */
function saveOptionsToCloudStorage() {
chrome.storage.sync.set({
// Saving General options
Expand Down