From c2b8df040edfe62a5502229868fa646385085ba3 Mon Sep 17 00:00:00 2001 From: Frederik <39029799+OMGeeky@users.noreply.github.com> Date: Sun, 8 Mar 2026 02:51:27 +0100 Subject: [PATCH 1/2] Fix Rust not showing messages of other users live Signed-off-by: Frederik <39029799+OMGeeky@users.noreply.github.com> --- docs/docs/00100-intro/00300-tutorials/00100-chat-app.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md b/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md index 2baa7ecb1d9..180572c9bd1 100644 --- a/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md +++ b/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md @@ -2556,7 +2556,8 @@ fn on_user_updated(_ctx: &EventContext, old: &User, new: &User) { #### Print messages -When we receive a new message, we'll print it to standard output, along with the name of the user who sent it. Keep in mind that we only want to do this for new messages, i.e. those inserted by a `send_message` reducer invocation. We have to handle the backlog we receive when our subscription is initialized separately, to ensure they're printed in the correct order. To that effect, our `on_message_inserted` callback will check if the ctx.event type is an `Event::Reducer`, and only print in that case. +When we receive a new message, we'll print it to standard output, along with the name of the user who sent it. Keep in mind that we only want to do this for new messages, i.e. those inserted by a `send_message` reducer invocation. We have to handle the backlog we receive when our subscription is initialized separately, to ensure they're printed in the correct order. To that effect, our `on_message_inserted` callback will check if the ctx.event type is an `Event::Reducer` (new local messages) or `Event::Transaction` (new messages from others), +and only print in that case. To find the `User` based on the message's `sender` identity, we'll use `ctx.db.user().identity().find(..)`, which behaves like the same function on the server. @@ -2569,7 +2570,7 @@ To `src/main.rs`, add: ```rust /// Our `Message::on_insert` callback: print new messages. fn on_message_inserted(ctx: &EventContext, message: &Message) { - if let Event::Reducer(_) = ctx.event { + if matches!(ctx.event, Event::Reducer(_) | Event::Transaction) { print_message(ctx, message) } } From e9d0d613f7fac2e92dbb1df2a585c09a12843914 Mon Sep 17 00:00:00 2001 From: Frederik <39029799+OMGeeky@users.noreply.github.com> Date: Sun, 8 Mar 2026 03:12:44 +0100 Subject: [PATCH 2/2] remove accidental new line Signed-off-by: Frederik <39029799+OMGeeky@users.noreply.github.com> --- docs/docs/00100-intro/00300-tutorials/00100-chat-app.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md b/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md index 180572c9bd1..c7cdd2f216c 100644 --- a/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md +++ b/docs/docs/00100-intro/00300-tutorials/00100-chat-app.md @@ -2556,8 +2556,7 @@ fn on_user_updated(_ctx: &EventContext, old: &User, new: &User) { #### Print messages -When we receive a new message, we'll print it to standard output, along with the name of the user who sent it. Keep in mind that we only want to do this for new messages, i.e. those inserted by a `send_message` reducer invocation. We have to handle the backlog we receive when our subscription is initialized separately, to ensure they're printed in the correct order. To that effect, our `on_message_inserted` callback will check if the ctx.event type is an `Event::Reducer` (new local messages) or `Event::Transaction` (new messages from others), -and only print in that case. +When we receive a new message, we'll print it to standard output, along with the name of the user who sent it. Keep in mind that we only want to do this for new messages, i.e. those inserted by a `send_message` reducer invocation. We have to handle the backlog we receive when our subscription is initialized separately, to ensure they're printed in the correct order. To that effect, our `on_message_inserted` callback will check if the ctx.event type is an `Event::Reducer` (new local messages) or `Event::Transaction` (new messages from others), and only print in that case. To find the `User` based on the message's `sender` identity, we'll use `ctx.db.user().identity().find(..)`, which behaves like the same function on the server.