Skip to content

Commit

Permalink
fix: lib classes marked async and await promises
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Mar 6, 2024
1 parent b2f85a1 commit 30a1183
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Client<

const signature = Buffer.from(sigBytes).toString('base64')

XMTPModule.receiveSignature(request.id, signature)
await XMTPModule.receiveSignature(request.id, signature)
} catch (e) {
const errorMessage = 'ERROR in create. User rejected signature'
console.info(errorMessage, e)
Expand All @@ -99,7 +99,7 @@ export class Client<
resolve(new Client(address, opts?.codecs || []))
}
)
XMTPModule.auth(
await XMTPModule.auth(
await signer.getAddress(),
options.env,
options.appVersion,
Expand All @@ -109,7 +109,9 @@ export class Client<
options.dbEncryptionKey,
options.dbPath
)
})()
})().catch((error) => {
console.error('ERROR in create: ', error)
})
})
}

Expand Down Expand Up @@ -256,9 +258,7 @@ export class Client<
return opts?.[event] !== undefined
}

private static async removeSubscription(
subscription?: Subscription
): Promise<void> {
private static removeSubscription(subscription?: Subscription) {
if (subscription) {
subscription.remove()
}
Expand Down
10 changes: 5 additions & 5 deletions src/lib/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ export class Conversation<ContentTypes extends DefaultContentTypes>
* @param {Function} callback - A callback function that will be invoked with the new DecodedMessage when a message is received.
* @returns {Function} A function that, when called, unsubscribes from the message stream and ends real-time updates.
*/
streamMessages(
async streamMessages(
callback: (message: DecodedMessage<ContentTypes>) => Promise<void>
): () => void {
XMTP.subscribeToMessages(this.client.address, this.topic)
): Promise<() => void> {
await XMTP.subscribeToMessages(this.client.address, this.topic)
const hasSeen = {}
const messageSubscription = XMTP.emitter.addListener(
EventTypes.ConversationMessage,
Expand All @@ -297,9 +297,9 @@ export class Conversation<ContentTypes extends DefaultContentTypes>
}
)

return () => {
return async () => {
messageSubscription.remove()
XMTP.unsubscribeFromMessages(this.client.address, this.topic)
await XMTP.unsubscribeFromMessages(this.client.address, this.topic)
}
}
}
10 changes: 5 additions & 5 deletions src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ export class Group<
* @param {Function} callback - A callback function that will be invoked with the new DecodedMessage when a message is received.
* @returns {Function} A function that, when called, unsubscribes from the message stream and ends real-time updates.
*/
streamGroupMessages(
async streamGroupMessages(
callback: (message: DecodedMessage<ContentTypes>) => Promise<void>
): () => void {
XMTP.subscribeToGroupMessages(this.client.address, this.id)
): Promise<() => void> {
await XMTP.subscribeToGroupMessages(this.client.address, this.id)
const hasSeen = {}
const messageSubscription = XMTP.emitter.addListener(
EventTypes.GroupMessage,
Expand All @@ -150,9 +150,9 @@ export class Group<
await callback(DecodedMessage.fromObject(message, this.client))
}
)
return () => {
return async () => {
messageSubscription.remove()
XMTP.unsubscribeFromGroupMessages(this.client.address, this.id)
await XMTP.unsubscribeFromGroupMessages(this.client.address, this.id)
}
}

Expand Down

0 comments on commit 30a1183

Please sign in to comment.