Address feedback from https://phab.comm.dev/D12944?id=43066#inline-75283
Extracted sending Olm messages (and optional session creation) to a hook.
It is used in a few places, which are updated in subsequent diffs
Details
- Reviewers
kamil - Commits
- rCOMM484a1c2b5690: [lib] Add hook to broadcast Olm-encrypted messages
Flow. Logic tested in later diffs
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
lib/hooks/peer-list-hooks.js | ||
---|---|---|
147 ↗ | (On Diff #43165) | In most use cases we'll want to use PeerToPeerProvider and persist messages until confirmation from a recipient (code here), This is different because we're about to log out so there is no need to persist, we also don't expect to receive the confirmation. I think it will be beneficial to reflect that in the name to avoid confusion, something like useBroadcastEphemeralOlmMessage or useBroadcastOlmMessageWithoutPersiting. Alternatively, what do you think about making this hook as part of PeerToPeerProvider ? From this point every P2P communication should be implemented using usePeerToPeerCommunication hook. |
169–210 ↗ | (On Diff #43165) | How about creating a promise for each recipient and then using Promise.all? |
184 ↗ | (On Diff #43165) | we should filter errors here - but this is part of my work. |
lib/hooks/peer-list-hooks.js | ||
---|---|---|
162–166 ↗ | (On Diff #43165) | Looking at call sites we always have a getAuthMetadata call before, and I think we'll have the same in other use cases. Maybe we can pass AuthMetadata as a param here to avoid unnecessary calls? |