Skip to content

Commit

Permalink
Merge branch 'unittestharness' of https://github.com/xmtp/xmtp-react-…
Browse files Browse the repository at this point in the history
…native into unittestharness
  • Loading branch information
nakajima committed May 3, 2023
2 parents cae81d2 + eda0ec5 commit 1681da1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class XMTPModule : Module() {
findConversation(topic = topic, conversationId = conversationId) ?: return
subscriptions[conversation.cacheKey] = CoroutineScope(Dispatchers.IO).launch {
try {
conversation.streamMessages().collect() { message ->
conversation.streamMessages().collect { message ->
sendEvent(
"message",
mapOf(
Expand Down
12 changes: 2 additions & 10 deletions example/src/ConversationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,11 @@ export default function ConversationView({ route }: Props): JSX.Element {

useEffect(() => {
const unsubscribe = conversation.streamMessages(async (message) => {
const uniqueMessages = [
...new Map(
[message, ...messages].map((item: DecodedMessage) => [item.id, item])
).values(),
].sort((a, b) => {
return a.sent > b.sent ? 1 : -1;
});

setMessages(uniqueMessages);
await loadMessages();
});

return unsubscribe;
});
}, []);

return (
<>
Expand Down

0 comments on commit 1681da1

Please sign in to comment.