Browse Source

Refactor comments, yet again

imwald
Nuša Pukšič 3 months ago
parent
commit
06f23cf6c8
  1. 2
      assets/controllers/comments_mercure_controller.js
  2. 3
      src/Twig/Components/Organisms/Comments.php

2
assets/controllers/comments_mercure_controller.js

@ -23,7 +23,7 @@ export default class extends Controller { @@ -23,7 +23,7 @@ export default class extends Controller {
this.es = new EventSource(url.toString());
this.es.onmessage = async (msg) => {
this.component.set('payloadJson', msg.data);
this.component.action('loadComments', { payload: msg.data });
this.component.action('loadComments', { 'payload': msg.data });
await this.component.render();
};
}

3
src/Twig/Components/Organisms/Comments.php

@ -9,6 +9,7 @@ use Symfony\Component\Messenger\Exception\ExceptionInterface; @@ -9,6 +9,7 @@ use Symfony\Component\Messenger\Exception\ExceptionInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveArg;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\DefaultActionTrait;
@ -57,7 +58,7 @@ final class Comments @@ -57,7 +58,7 @@ final class Comments
}
#[LiveAction]
public function loadComments($payload): array
public function loadComments(#[LiveArg] string $payload): array
{
$data = json_decode($payload);

Loading…
Cancel
Save