mercure-chat-tutorial icon indicating copy to clipboard operation
mercure-chat-tutorial copied to clipboard

after pressing enter, the message is displayed two times

Open ecarsmd opened this issue 5 years ago • 11 comments

when I send the "post" message, it is displayed two times as in the following video - https://www.youtube.com/watch?v=pdMh7e4kO-M do you know why this happens?

ecarsmd avatar Sep 25 '20 11:09 ecarsmd

I have same problem, help please

e1sep0 avatar Oct 13 '20 08:10 e1sep0

Hello there, I'm so sorry I did not see the original post by @ecarsmd i just got notified now about this.

Please make sure that you are using the version that I used in the video, because they changed so much with the newer versions and they also removed the mechanism that sends the messages to a single target which is what is causing the message to be displayed twice.

The mercure version that I used was: ^0.2.3 The binary can be downloaded from here: https://github.com/dunglas/mercure/releases/tag/v0.10.0

If the problem persists please let me know

konshensx16 avatar Oct 13 '20 13:10 konshensx16

Hello, I took last mercure bundle: "symfony/mercure-bundle": "^0.2.5", I made some changes in Message controller:

        $update = new Update(
            [
                sprintf("/conversations/%s", $conversation->getId()),
                sprintf("/conversations/%s", $recipient->getUser()->getUsername()),
            ],
            $messageSerialized
        );

And changes in Index Controller:

$token = (new Builder())
            ->withClaim('mercure', ['subscribe' => [sprintf("/conversations/%s", $username)]])
            ->getToken(
                new Sha256(),
                new Key($this->getParameter('mercure_secret_key'))
            )
        ;

Recipient get One message, But Sender views self message twice: image

Maybe some problem in Vue files ? Thank you. mercury bundle 0.2.3 i can`t install unfortunately

e1sep0 avatar Oct 13 '20 13:10 e1sep0

I can leave only one topic in MessageController, but then updates only Left side (Recent)

e1sep0 avatar Oct 13 '20 13:10 e1sep0

I decided this problem, installed mercury 0.3.0. Thank you. But got new one( Sometimes page redirects after message sending, do you know why and how to fix it ? Thanks a lot )

e1sep0 avatar Oct 13 '20 16:10 e1sep0

Hm that is really weird, which page do you get redirected to ? Also do you get redirect in the Vue app ? like the url changes ? or just when you take a look at the XHR request is says 302 redirected ?

konshensx16 avatar Oct 13 '20 19:10 konshensx16

After first message in chat pages refreshes, in profiler i see 301 redirect: image After this refresh chat works without this refreshing. Maybe something with auth?

e1sep0 avatar Oct 14 '20 07:10 e1sep0

I decided this problem, installed mercury 0.3.0. Thank you. But got new one( Sometimes page redirects after message sending, do you know why and how to fix it ? Thanks a lot )

mercure-bundle 0.2.5 and mercure 0.3.0 ?

ecarsmd avatar Nov 04 '20 14:11 ecarsmd

I decided this problem, installed mercury 0.3.0. Thank you. But got new one( Sometimes page redirects after message sending, do you know why and how to fix it ? Thanks a lot )

mercure-bundle 0.2.5 and mercure 0.3.0 ?

"symfony/mercure": "^0.3",
"symfony/mercure-bundle": "^0.2.5",

e1sep0 avatar Nov 04 '20 15:11 e1sep0

I decided this problem, installed mercury 0.3.0. Thank you. But got new one( Sometimes page redirects after message sending, do you know why and how to fix it ? Thanks a lot )

mercure-bundle 0.2.5 and mercure 0.3.0 ?

"symfony/mercure": "^0.3",
"symfony/mercure-bundle": "^0.2.5",

to me the problem persists (

ecarsmd avatar Nov 05 '20 12:11 ecarsmd

to me the problem persists (

I found solution: in assets/js/components/Right/Input.vue change line: in form <form action="#"> add onsubmit event and remove action: <form onsubmit="event.preventDefault();">

e1sep0 avatar Nov 11 '20 13:11 e1sep0