Skip to content

Commit

Permalink
fix(chat): send message after store&publish
Browse files Browse the repository at this point in the history
  • Loading branch information
molimauro authored and stavares843 committed Sep 19, 2022
1 parent f40b193 commit f521efc
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions libraries/Iridium/chat/ChatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,32 +730,36 @@ export default class ChatManager extends Emitter<ConversationMessage> {
...partial,
id: tempCid.toString() as string,
}
await iridium.connector.publish(
`/chat/conversations/${conversationId}`,
{
type: 'chat/message',
cid: tempCid.toString() as string,
message,
},
{

await Promise.all([
iridium.connector?.store(partial, {
syncPin: true,
encrypt: conversation?.participants
? { recipients: conversation.participants }
? { recipients: conversation?.participants }
: undefined,
},
)
}),
iridium.connector?.publish(
`/chat/conversations/${conversationId}`,
{
type: 'chat/message',
cid: tempCid.toString() as string,
message,
},
{
encrypt: conversation?.participants
? { recipients: conversation.participants }
: undefined,
},
),
])

Vue.set(
this.state.conversations[conversationId].message,
message.id,
message,
)
Vue.set(this.state.conversations[conversationId], 'lastReadAt', Date.now())

iridium.connector.store(partial, {
syncPin: true,
encrypt: conversation?.participants
? { recipients: conversation?.participants }
: undefined,
})
if (message.id === undefined) {
throw new Error('message not sent, failed to store')
}
Expand Down

0 comments on commit f521efc

Please sign in to comment.