@@ -5,19 +5,26 @@ use Magento\Framework\View\Element\Template;
55
66/** @version 1.0.4 */
77/** @var Template $block */
8+
9+ $ fetchLocalStorage = !(bool )$ block ->getSkipLocalStorage ();
10+ $ fetchCookies = !(bool )$ block ->getSkipCookies ();
811?>
912<script>
1013 document.addEventListener('alpine:init', () => {
1114 Alpine.store('LokiMessageStore', {
1215 messages: [],
16+ fetchLocalStorage: <?= /* @noEscape */ $ fetchLocalStorage ? 'true ' : 'false ' ?> ,
17+ fetchCookies: <?= /* @noEscape */ $ fetchLocalStorage ? 'true ' : 'false ' ?> ,
1318 init() {
14- Alpine.effect(() => {
15- const messageSection = Alpine.store('LokiLocalStorage').get('messages');
16- if (messageSection && messageSection.messages) {
17- this.messages = [...this.messages, ...messageSection.messages];
18- this.reset();
19- }
20- });
19+ if (this.fetchLocalStorage) {
20+ Alpine.effect(() => {
21+ const messageSection = Alpine.store('LokiLocalStorage').get('messages');
22+ if (messageSection && messageSection.messages) {
23+ this.messages = [...this.messages, ...messageSection.messages];
24+ this.reset();
25+ }
26+ });
27+ }
2128 },
2229 getMessages() {
2330 const cookieMessages = this.getCookieMessages();
@@ -29,6 +36,10 @@ use Magento\Framework\View\Element\Template;
2936 return this.messages;
3037 },
3138 getCookieMessages() {
39+ if (!this.fetchCookies) {
40+ return [];
41+ }
42+
3243 const cookieMessages = LokiCookies.get('mage-messages') || [];
3344 if (!cookieMessages instanceof Array) {
3445 LokiCookies.remove('mage-messages');
0 commit comments