summaryrefslogtreecommitdiffstats
path: root/web/react/stores/browser_store.jsx
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-12 12:45:15 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-18 08:59:26 -0400
commitfa1491bbfbb1261757943759edf44883d31e5477 (patch)
treeac5474908c28abf741371602603e22669cb4197e /web/react/stores/browser_store.jsx
parentc77f6041889b2dd8c6e830b8c2f42ab9c1340849 (diff)
downloadchat-fa1491bbfbb1261757943759edf44883d31e5477.tar.gz
chat-fa1491bbfbb1261757943759edf44883d31e5477.tar.bz2
chat-fa1491bbfbb1261757943759edf44883d31e5477.zip
finalize implenetation of predictive client posts so that users get immediate feedback after posting
Diffstat (limited to 'web/react/stores/browser_store.jsx')
-rw-r--r--web/react/stores/browser_store.jsx48
1 files changed, 30 insertions, 18 deletions
diff --git a/web/react/stores/browser_store.jsx b/web/react/stores/browser_store.jsx
index 4eed754cc..436b8d76d 100644
--- a/web/react/stores/browser_store.jsx
+++ b/web/react/stores/browser_store.jsx
@@ -3,7 +3,9 @@
var UserStore;
function getPrefix() {
- if (!UserStore) UserStore = require('./user_store.jsx');
+ if (!UserStore) {
+ UserStore = require('./user_store.jsx');
+ }
return UserStore.getCurrentId() + '_';
}
@@ -11,15 +13,15 @@ function getPrefix() {
var BROWSER_STORE_VERSION = '.4';
module.exports = {
- _initialized: false,
+ initialized: false,
- _initialize: function() {
- var currentVersion = localStorage.getItem("local_storage_version");
+ initialize: function() {
+ var currentVersion = localStorage.getItem('local_storage_version');
if (currentVersion !== BROWSER_STORE_VERSION) {
this.clear();
- localStorage.setItem("local_storage_version", BROWSER_STORE_VERSION);
+ localStorage.setItem('local_storage_version', BROWSER_STORE_VERSION);
}
- this._initialized = true;
+ this.initialized = true;
},
getItem: function(name, defaultValue) {
@@ -31,19 +33,25 @@ module.exports = {
},
removeItem: function(name) {
- if (!this._initialized) this._initialize();
+ if (!this.initialized) {
+ this.initialize();
+ }
localStorage.removeItem(getPrefix() + name);
},
setGlobalItem: function(name, value) {
- if (!this._initialized) this._initialize();
+ if (!this.initialized) {
+ this.initialize();
+ }
localStorage.setItem(name, JSON.stringify(value));
},
getGlobalItem: function(name, defaultValue) {
- if (!this._initialized) this._initialize();
+ if (!this.initialized) {
+ this.initialize();
+ }
var result = null;
try {
@@ -58,7 +66,9 @@ module.exports = {
},
removeGlobalItem: function(name) {
- if (!this._initialized) this._initialize();
+ if (!this.initialized) {
+ this.initialize();
+ }
localStorage.removeItem(name);
},
@@ -70,10 +80,12 @@ module.exports = {
/**
* Preforms the given action on each item that has the given prefix
- * Signiture for action is action(key, value)
+ * Signature for action is action(key, value)
*/
- actionOnItemsWithPrefix: function (prefix, action) {
- if (!this._initialized) this._initialize();
+ actionOnItemsWithPrefix: function(prefix, action) {
+ if (!this.initialized) {
+ this.initialize();
+ }
var globalPrefix = getPrefix();
var globalPrefixiLen = globalPrefix.length;
@@ -87,14 +99,14 @@ module.exports = {
isLocalStorageSupported: function() {
try {
- sessionStorage.setItem("testSession", '1');
- sessionStorage.removeItem("testSession");
+ sessionStorage.setItem('testSession', '1');
+ sessionStorage.removeItem('testSession');
- localStorage.setItem("testLocal", '1');
- if (localStorage.getItem("testLocal") != '1') {
+ localStorage.setItem('testLocal', '1');
+ if (localStorage.getItem('testLocal') !== '1') {
return false;
}
- localStorage.removeItem("testLocal", '1');
+ localStorage.removeItem('testLocal', '1');
return true;
} catch (e) {