From 835638037a6e11cfdf4fd84c4b362465937a5bba Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 23 Jul 2014 18:24:49 +0200 Subject: Fix errors when using localStorage in Safari's private browsing mode (#1489996) Conflicts: program/js/app.js --- skins/larry/ui.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'skins') diff --git a/skins/larry/ui.js b/skins/larry/ui.js index f25c4fc1c..1c1df08be 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -76,7 +76,7 @@ function rcube_mail_ui() function get_pref(key) { if (!prefs) { - prefs = window.localStorage ? rcmail.local_storage_get_item('prefs.larry', {}) : {}; + prefs = rcmail.local_storage_get_item('prefs.larry', {}); } // fall-back to cookies @@ -85,9 +85,8 @@ function rcube_mail_ui() if (cookie != null) { prefs[key] = cookie; - // copy value to local storage and remove cookie - if (window.localStorage) { - rcmail.local_storage_set_item('prefs.larry', prefs); + // copy value to local storage and remove cookie (if localStorage is supported) + if (rcmail.local_storage_set_item('prefs.larry', prefs)) { rcmail.set_cookie(key, cookie, new Date()); // expire cookie } } @@ -103,11 +102,8 @@ function rcube_mail_ui() { prefs[key] = val; - // write prefs to local storage - if (window.localStorage) { - rcmail.local_storage_set_item('prefs.larry', prefs); - } - else { + // write prefs to local storage (if supported) + if (!rcmail.local_storage_set_item('prefs.larry', prefs)) { // store value in cookie var exp = new Date(); exp.setYear(exp.getFullYear() + 1); -- cgit v1.2.3