From 7bde3656e4aae78856ba836361374d5124e7c45d Mon Sep 17 00:00:00 2001 From: Phil Date: Tue, 4 Feb 2014 18:04:04 +1000 Subject: [PATCH] Fixed bug with loading default user preferences if user doesn't yet have any preferenced --- src/components/models/userProfile.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/models/userProfile.js b/src/components/models/userProfile.js index d2452cfe..631128c6 100644 --- a/src/components/models/userProfile.js +++ b/src/components/models/userProfile.js @@ -17,7 +17,11 @@ baw.UserProfile = (function () { if (!defaultProfile) { throw new Error("A default profile must be supplied"); } - + + + profile.preferences = profile.preferences || {}; + + // make read only properties for all profile props returned var props = Object.keys(profile) .reduce(function (state, current, index, array) { @@ -37,7 +41,7 @@ baw.UserProfile = (function () { if (!merged.hasOwnProperty(key)) { return; } - + this.preferences[key] = merged[key]; } }