From a6c97490b3c6b7bca00d16bc436abf902ee7b101 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Mon, 25 Jan 2016 10:40:29 -0500
Subject: Changed first preference load to be done synchronously

---
 web/react/stores/preference_store.jsx | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

(limited to 'web/react/stores/preference_store.jsx')

diff --git a/web/react/stores/preference_store.jsx b/web/react/stores/preference_store.jsx
index 79eab4fe1..7ecaf0a95 100644
--- a/web/react/stores/preference_store.jsx
+++ b/web/react/stores/preference_store.jsx
@@ -133,6 +133,16 @@ class PreferenceStoreClass extends EventEmitter {
         return preference;
     }
 
+    setPreferences(newPreferences) {
+        const preferences = this.getAllPreferences();
+
+        for (const preference of newPreferences) {
+            preferences.set(getPreferenceKeyForModel(preference), preference);
+        }
+
+        this.setAllPreferences(preferences);
+    }
+
     emitChange() {
         this.emit(CHANGE_EVENT);
     }
@@ -155,18 +165,11 @@ class PreferenceStoreClass extends EventEmitter {
             this.emitChange();
             break;
         }
-        case ActionTypes.RECIEVED_PREFERENCES: {
-            const preferences = this.getAllPreferences();
-
-            for (const preference of action.preferences) {
-                preferences.set(getPreferenceKeyForModel(preference), preference);
-            }
-
-            this.setAllPreferences(preferences);
+        case ActionTypes.RECIEVED_PREFERENCES:
+            this.setPreferences(action.preferences);
             this.emitChange();
             break;
         }
-        }
     }
 }
 
-- 
cgit v1.2.3-1-g7c22

