Skip to content

Commit f56efc2

Browse files
committed
feat(samples): update parent message reactively in ThreadPage
Update `ThreadPage` in `thread_list_page.dart` to use `BetterStreamBuilder` to listen for updates to the parent message from the channel's message stream. This ensures the parent message remains up-to-date within the thread view.
1 parent f87b36b commit f56efc2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sample_app/lib/pages/thread_list_page.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,16 @@ class _ThreadListPageState extends State<ThreadListPage> {
5050
return StreamChannel(
5151
channel: channel,
5252
initialMessageId: thread.draft?.parentId,
53-
child: ThreadPage(parent: thread.parentMessage!),
53+
child: BetterStreamBuilder(
54+
stream: channel.state?.messagesStream.map(
55+
(messages) => messages.firstWhere(
56+
(m) => m.id == thread.parentMessage!.id,
57+
),
58+
),
59+
builder: (_, parentMessage) {
60+
return ThreadPage(parent: parentMessage);
61+
},
62+
),
5463
);
5564
},
5665
),

0 commit comments

Comments
 (0)