Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Fix standard errors
Browse files Browse the repository at this point in the history
  • Loading branch information
muan committed Aug 23, 2017
1 parent 4fea3ad commit 7335ea6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions app/search.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global localStorage, fetch */
var emojilib = JSON.parse(localStorage.getItem('emojilib')) || require('emojilib').lib
var emojikeys = JSON.parse(localStorage.getItem('emojikeys')) || require('emojilib').ordered
var modifiers = require('emojilib').fitzpatrick_scale_modifiers
Expand All @@ -8,7 +9,7 @@ var indexKeys = Object.keys(index)
var emojikeyIndexTable = buildEmojikeyIndexTable()
var searching = false
var searchInput = document.querySelector('.js-search')
var preference = JSON.parse(window.localStorage.getItem('preference'))
var preference = JSON.parse(localStorage.getItem('preference'))
var directions = {
37: 'left',
38: 'up',
Expand All @@ -24,15 +25,15 @@ function fetchAndUpdateLocalCache () {
var emojilibLib = `https://unpkg.com/emojilib@${version}/emojis.json`
var emojilibOrdered = `https://unpkg.com/emojilib@${version}/ordered.json`

fetch(emojilibLib).then(function (res) { return checkIfNewVersion(res) }).then(function(newData) {
fetch(emojilibLib).then(function (res) { return checkIfNewVersion(res) }).then(function (newData) {
// Fetch only once per day
localStorage.setItem('emojilibExpireTime', new Date().getTime() + 1000 * 60 * 60 * 24)
if (!newData) return
localStorage.setItem('emojilib', JSON.stringify(newData))

fetch(emojilibOrdered).then(function (res) { return res.json() }).then(function(newData) {
fetch(emojilibOrdered).then(function (res) { return res.json() }).then(function (newData) {
localStorage.setItem('emojikeys', JSON.stringify(newData))
location.reload()
window.location.reload()
})
})

Expand Down
13 changes: 7 additions & 6 deletions app/settings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global localStorage, alert */
var preference
var ipc = require('electron').ipcRenderer
var modifiers = require('emojilib').fitzpatrick_scale_modifiers
Expand All @@ -17,7 +18,7 @@ var preferenceNames = {
}

var applyPreferences = function (preference, initialization) {
window.localStorage.setItem('preference', JSON.stringify(preference))
localStorage.setItem('preference', JSON.stringify(preference))

ipc.send('update-preference', preference, initialization)
var style = document.createElement('style')
Expand All @@ -39,8 +40,8 @@ var savePreference = function (event) {
applyPreferences(preference)
}

if (window.localStorage.getItem('preference')) {
preference = JSON.parse(window.localStorage.getItem('preference'))
if (localStorage.getItem('preference')) {
preference = JSON.parse(localStorage.getItem('preference'))
Object.keys(defaultPreference).forEach(function (key) {
if (!preference[key]) preference[key] = defaultPreference[key]
})
Expand All @@ -57,11 +58,11 @@ ipc.on('open-preference', function (event, message) {
ipc.on('preference-updated', function (event, result, initialization) {
if (result) {
if (!initialization) {
window.alert('Saved!')
alert('Saved!')
togglePreferencePanel()
}
} else {
window.alert('Something went wrong, likely related to keybindings. See http://electron.atom.io/docs/v0.36.5/api/accelerator/ for more.')
alert('Something went wrong, likely related to keybindings. See http://electron.atom.io/docs/v0.36.5/api/accelerator/ for more.')
}
})

Expand All @@ -70,7 +71,7 @@ var togglePreferencePanel = function () {
document.body.classList.remove('on-preference')
document.getElementById('js-preference-panel').remove()
} else {
var preference = JSON.parse(window.localStorage.getItem('preference'))
var preference = JSON.parse(localStorage.getItem('preference'))
var panel = document.createElement('div')

panel.classList.add('preference-panel')
Expand Down

0 comments on commit 7335ea6

Please sign in to comment.