replace new Promise in observer
This commit is contained in:
parent
54fadb0cd2
commit
260d4a4001
|
@ -102,7 +102,7 @@ export class Community {
|
||||||
) => {
|
) => {
|
||||||
const id = `${this.communityPublicKey}${channelId}`
|
const id = `${this.communityPublicKey}${channelId}`
|
||||||
const channelContentTopic = idToContentTopic(id)
|
const channelContentTopic = idToContentTopic(id)
|
||||||
// todo: keep in state instead and replace the factory
|
// todo?: keep in state instead and replace the factory
|
||||||
const symKey = await createSymKeyFromPassword(id)
|
const symKey = await createSymKeyFromPassword(id)
|
||||||
|
|
||||||
return async (options: { start: Date; end?: Date }) => {
|
return async (options: { start: Date; end?: Date }) => {
|
||||||
|
@ -134,21 +134,19 @@ export class Community {
|
||||||
}
|
}
|
||||||
|
|
||||||
private observeChannelMessages = async (chatsIds: string[]) => {
|
private observeChannelMessages = async (chatsIds: string[]) => {
|
||||||
const symKeyPromises = chatsIds.map((chatId: string) => {
|
const symKeyPromises = chatsIds.map(async (chatId: string) => {
|
||||||
return new Promise<string>(resolve => {
|
const id = `${this.communityPublicKey}${chatId}`
|
||||||
const id = `${this.communityPublicKey}${chatId}`
|
const channelContentTopic = idToContentTopic(id)
|
||||||
const channelContentTopic = idToContentTopic(id)
|
|
||||||
|
|
||||||
createSymKeyFromPassword(id).then(symKey => {
|
const symKey = await createSymKeyFromPassword(id)
|
||||||
// todo: request waku feature to be passed as param
|
|
||||||
this.waku.relay.addDecryptionKey(symKey, {
|
|
||||||
method: waku_message.DecryptionMethod.Symmetric,
|
|
||||||
contentTopics: [channelContentTopic],
|
|
||||||
})
|
|
||||||
|
|
||||||
resolve(channelContentTopic)
|
// todo?: request waku feature to be passed as param
|
||||||
})
|
this.waku.relay.addDecryptionKey(symKey, {
|
||||||
|
method: waku_message.DecryptionMethod.Symmetric,
|
||||||
|
contentTopics: [channelContentTopic],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return channelContentTopic
|
||||||
})
|
})
|
||||||
const contentTopics = await Promise.all(symKeyPromises)
|
const contentTopics = await Promise.all(symKeyPromises)
|
||||||
|
|
||||||
|
@ -207,11 +205,6 @@ export class Community {
|
||||||
// state
|
// state
|
||||||
const channelId = messages[0].channelId
|
const channelId = messages[0].channelId
|
||||||
|
|
||||||
// todo: don't use; insert in-place
|
|
||||||
// const sortedMessages = sortBy(messages, ['timestamp'])
|
|
||||||
// todo: don't use; check prior insert
|
|
||||||
// const uniqueChannelMessages = uniqBy(sortedMessages, 'messageId')
|
|
||||||
// todo?: remove undefined left after deletion
|
|
||||||
this.channelMessages[channelId] = messages
|
this.channelMessages[channelId] = messages
|
||||||
|
|
||||||
// callback
|
// callback
|
||||||
|
|
Loading…
Reference in New Issue