Skip to content

Commit cec7d6d

Browse files
committed
Add compatibility with MageOS_AlpineLoader
1 parent cb125ec commit cec7d6d

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

view/base/layout/loki_alpinejs.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
44
<body>
55
<referenceBlock name="loki.script">
6-
<block name="loki.alpinejs" template="Loki_Base::script/alpine-csp.phtml"/>
6+
<block name="loki.alpinejs" template="Loki_Base::script/alpine-csp.phtml">
7+
<arguments>
8+
<argument name="module_config" xsi:type="object">Loki\Base\ViewModel\ModuleConfig</argument>
9+
</arguments>
10+
</block>
711
</referenceBlock>
812
</body>
913
</page>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<?php declare(strict_types=1);
22

3+
use Loki\Base\ViewModel\ModuleConfig;
34
use Magento\Framework\View\Element\Template;
45

56
/** @version 1.1.10 */
67
/** @var Template $block */
8+
/** @var ModuleConfig $moduleConfig */
79

810
$jsUrl = $block->getViewFileUrl('Loki_Base::js/alpine-csp.js');
911
$defer = (bool)$block->getDefer();
12+
$moduleConfig = $block->getModuleConfig();
13+
14+
if ($moduleConfig->isEnabled('MageOS_AlpineLoader')) {
15+
return;
16+
}
1017
?>
1118
<script defer src="<?= /* @noEscape */ $jsUrl ?>" <?php if ($defer) : ?>defer<?php endif; ?>></script>

view/base/templates/script/component/message-component.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if (false === is_numeric($timeout) || $timeout < 0) {
2121
timeout: <?= (int)$timeout ?>,
2222
init() {
2323
Alpine.effect(() => {
24+
console.log('Fetching messages...');
2425
this.messages = Alpine.store('Message').getMessages();
2526
});
2627
},

0 commit comments

Comments
 (0)