Handle undefined in key translator.

pull/611/head
Rick Carlino 2018-01-10 14:28:59 -06:00
parent ade9103571
commit 6db916b46f
2 changed files with 4 additions and 4 deletions

View File

@ -206,13 +206,11 @@ export let botReducer = generateReducer<BotState>(initialState(), afterEach)
const isDown = status.state === "down";
if (isBotMqtt) { /** This is way too hard to maintain */
if (isDown) {
console.log("~STASHING~");
stashStatus(s);
s.hardware.informational_settings.sync_status = undefined;
} else {
const botMqtt = s.connectivity["bot.mqtt"];
if (botMqtt && botMqtt.state === "down") { // Going from "down" to "up"
console.log("~UNSTASHING~");
s.hardware.informational_settings.sync_status = s.statusStash;
}
}

View File

@ -16,8 +16,10 @@ const eachEntry = (): KeyTranslationPair[] => {
.map(key => ({ jsCaseKey: camelCase(key), ruby_case_key: key, value: key }));
};
const transferKey = (x: KeyTranslationPair) =>
localStorage.setItem(x.ruby_case_key, localStorage.getItem(x.jsCaseKey) || "");
const transferKey = (x: KeyTranslationPair) => {
const item = localStorage.getItem(x.jsCaseKey);
item && localStorage.setItem(x.ruby_case_key, item);
};
export const DONE_FLAG = "done";