From: Alexander Ebert Date: Fri, 26 Aug 2016 12:00:28 +0000 (+0200) Subject: Improved autosave cleanup, fixes #2095 X-Git-Tag: 3.0.0_Beta_1~487 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1608618560be986f38603605256852029fb11066;p=GitHub%2FWoltLab%2FWCF.git Improved autosave cleanup, fixes #2095 --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js index 74fc977ebe..d964565cef 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js @@ -160,9 +160,9 @@ define(['Dom/Traverse'], function(DomTraverse) { * @protected */ _cleanup: function () { - var oneWeekAgo = Date.now() - (7 * 24 * 3600 * 1000); - var key, value; - for (var i = 0, length = window.localStorage.length; i < length; i++) { + var oneWeekAgo = Date.now() - (7 * 24 * 3600 * 1000), removeKeys = []; + var i, key, length, value; + for (i = 0, length = window.localStorage.length; i < length; i++) { key = window.localStorage.key(i); // check if key matches our prefix @@ -185,12 +185,16 @@ define(['Dom/Traverse'], function(DomTraverse) { } if (!value || value.timestamp < oneWeekAgo) { - try { - window.localStorage.removeItem(key); - } - catch (e) { - window.console.warn("Unable to remove from local storage: " + e.message); - } + removeKeys.push(key); + } + } + + for (i = 0, length = removeKeys.length; i < length; i++) { + try { + window.localStorage.removeItem(removeKeys[i]); + } + catch (e) { + window.console.warn("Unable to remove from local storage: " + e.message); } } }