Skip to content

Commit b258f4c

Browse files
committed
ACP2E-2957: move logic from cookie to local storage to avoid cookie size too large error
1 parent 68e6868 commit b258f4c

File tree

1 file changed

+7
-9
lines changed
  • app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/action

1 file changed

+7
-9
lines changed

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/action/deleteImages.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ define([
99
'Magento_MediaGalleryUi/js/grid/messages',
1010
'Magento_Ui/js/modal/confirm',
1111
'mage/translate',
12-
'mage/cookies'
12+
'jquery/jquery-storageapi'
1313
], function ($, _, urlBuilder, messages, confirmation, $t) {
1414
'use strict';
1515

@@ -30,9 +30,11 @@ define([
3030

3131
Object.values(recordIds).forEach(function (recordId) {
3232
if (typeof recordId === 'string') {
33-
imageLinks.push(
33+
let imageUrl = new URL(
3434
$('div[data-id=' + recordId + ']').find('img').attr('src').replace('.thumbs', '')
3535
);
36+
37+
imageLinks.push(imageUrl.pathname);
3638
}
3739
});
3840

@@ -74,14 +76,10 @@ define([
7476
});
7577
deferred.resolve(message);
7678

77-
let options = {
78-
secure: window.cookiesConfig ? window.cookiesConfig.secure : false
79-
};
80-
81-
if ($.mage.cookies.get('deleted_images')) {
82-
imageLinks = imageLinks.concat(JSON.parse($.mage.cookies.get('deleted_images')));
79+
if ($.localStorage.get('deleted_images')) {
80+
imageLinks = imageLinks.concat($.localStorage.get('deleted_images'));
8381
}
84-
$.mage.cookies.set('deleted_images', JSON.stringify(imageLinks), options);
82+
$.localStorage.set('deleted_images', [...new Set(imageLinks)]);
8583
},
8684

8785
/**

0 commit comments

Comments
 (0)