Skip to content

Commit

Permalink
Merge pull request #669 from adaptlearning/issue/#663
Browse files Browse the repository at this point in the history
Changed user preferences to be session based
  • Loading branch information
brian-learningpool committed May 7, 2015
2 parents 8494049 + 0323ed4 commit fd8cb7a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions frontend/src/core/app/views/originView.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,19 @@ define(function(require){
setUserPreference: function(key, value) {
if (this.settings.preferencesKey && typeof(Storage) !== "undefined") {
// Get preferences for this view
var preferences = localStorage.getItem(this.settings.preferencesKey);
// Convert string to JSON
var json = (JSON.parse(preferences) || {});
var preferences = (Origin.sessionModel.get(this.settings.preferencesKey) || {});
// Set key and value
json[key] = value;
preferences[key] = value;
// Store in localStorage
localStorage.setItem(this.settings.preferencesKey, JSON.stringify(json));
Origin.sessionModel.set(this.settings.preferencesKey, preferences);

}
},

getUserPreferences: function() {
if (this.settings.preferencesKey && typeof(Storage) !== "undefined"
&& localStorage.getItem(this.settings.preferencesKey)) {
return JSON.parse(localStorage.getItem(this.settings.preferencesKey));
return Origin.sessionModel.get(this.settings.preferencesKey);
} else {
return {};
}
Expand Down

0 comments on commit fd8cb7a

Please sign in to comment.