Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine
Next Chapter

Challenge #1 of 1


Q: 

In my chat application, whenever a user sends a message to the chat, I return a turbo stream message to update all of the user's pages with the new message. My stream code looks like this:

<turbo-stream action="update" id="new-messages-{{ chat.id }}">
    <template>
        {% for message in chat.newMessages %}
            <div class="message">
                <span class="user">{{ message.from }}</span>:
                {{ message.text }}
            </div>
        {% endfor %}
    </template>
</turbo-stream>

But whenever a user sends a message, the entire chat room disappears and only shows the last messages. Why? And how can I fix it?

userVoice