We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 683c614 commit 079cdbaCopy full SHA for 079cdba
1 file changed
view/frontend/templates/script/store/localstorage-store.phtml
@@ -15,11 +15,24 @@ use Magento\Framework\View\Element\Template;
15
data: {},
16
init() {
17
const storedData = localStorage.getItem(this.key);
18
- this.data = storedData ? JSON.parse(storedData) : null;
+ this.data = storedData ? JSON.parse(storedData) : {};
19
20
if (!this.data) {
21
this.refresh();
22
}
23
+
24
+ let changed = false;
25
+ Object.entries(this.data).forEach(([key, value]) => {
26
+ if (value.data_id && value.data_id < Date. now()) {
27
+ delete this.data[key];
28
+ changed = true;
29
+ }
30
+ })
31
32
33
+ if (changed) {
34
+ localStorage.setItem(this.key, JSON.stringify(this.data));
35
36
},
37
save() {
38
localStorage.setItem(this.key, JSON.stringify(this.data));
0 commit comments