diff options
author | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-06-18 13:37:39 -0700 |
---|---|---|
committer | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-06-18 13:37:39 -0700 |
commit | 2082ee5bdc69d6331db64af64ff686b99ddddd55 (patch) | |
tree | 7fbb5ca255971234342b8859bf2dee8bdf978ac5 /web/react/utils | |
parent | 19e9a4121820a1ad124a4189837c8c4088c33439 (diff) | |
download | chat-2082ee5bdc69d6331db64af64ff686b99ddddd55.tar.gz chat-2082ee5bdc69d6331db64af64ff686b99ddddd55.tar.bz2 chat-2082ee5bdc69d6331db64af64ff686b99ddddd55.zip |
Added a util function that checks that local/session storage is enabled. Also added tests using this function to report an error to the user if it is not enabled
Diffstat (limited to 'web/react/utils')
-rw-r--r-- | web/react/utils/utils.jsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index e57088614..0a0812c42 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -96,6 +96,21 @@ module.exports.getCookie = function(name) { if (parts.length == 2) return parts.pop().split(";").shift(); } +module.exports.isLocalStorageSupported = function() { + try { + sessionStorage.setItem("testSession", '1'); + sessionStorage.removeItem("testSession"); + + localStorage.setItem("testLocal", '1'); + localStorage.removeItem("testLocal", '1'); + + return true; + } + catch (e) { + return false; + } +} + module.exports.notifyMe = function(title, body, channel) { if ("Notification" in window && Notification.permission !== 'denied') { Notification.requestPermission(function (permission) { |