From b149e37aad7e41299845c48e8ee8ee715825044d Mon Sep 17 00:00:00 2001 From: Etienne Lemay Date: Mon, 1 May 2017 11:18:40 +0200 Subject: [PATCH] Update frequently defaults quantity when still unchanged --- src/utils/frequently.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/frequently.js b/src/utils/frequently.js index f9b5721..e4e41c1 100644 --- a/src/utils/frequently.js +++ b/src/utils/frequently.js @@ -20,11 +20,12 @@ const DEFAULTS = [ ] let frequently = store.get('frequently') +let defaults = {} function add(emoji) { var { id } = emoji - frequently || (frequently = {}) + frequently || (frequently = defaults) frequently[id] || (frequently[id] = 0) frequently[id] += 1 @@ -34,10 +35,11 @@ function add(emoji) { function get(perLine) { if (!frequently) { - frequently = {} + defaults = {} - Array(perLine).fill('').forEach((_, i) => { - frequently[DEFAULTS[i]] = perLine - i + return Array(perLine).fill('').map((_, i) => { + defaults[DEFAULTS[i]] = perLine - i + return DEFAULTS[i] }) }