* Replace `pendingEventEncryption` with a Set
We don't actually need the promise, so no need to save it.
This also fixes a resource leak, where we would leak a Promise and a HashMap
entry on each encrypted event.
* Convert `encryptEventIfNeeded` to async function
This means that it will always return a promise, so `encryptAndSendEvent` can't
tell if we are actually encrypting or not. Hence, also move the
`updatePendingEventStatus` into `encryptEventIfNeeded`.
* Simplify `encryptAndSendEvent`
Rewrite this as async.
* Factor out `MatrixClient.shouldEncryptEventForRoom`
* Inline a call to `isRoomEncrypted`
I want to deprecate this thing
* Retry to-device messages
This adds a queueToDevice API alongside sendToDevice which is a
much higher-level API that adds the messages to a queue, stored in
persistent storage, and retries them periodically. Also converts
sending of megolm keys to use the new API.
Other uses of sendToDevice are nopt converted in this PR, but could
be later.
Requires https://github.com/matrix-org/matrix-mock-request/pull/17
* Bump matrix-mock-request
* Add more waits to make indexeddb tests pass
* Switch some test expectations to queueToDevice
* Stop straight away if the client has been stopped
Hopefully will fix tests being flakey and logging after tests have
finished.
* Add return types & fix constant usage
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Fix return type
Co-authored-by: Germain <germains@element.io>
* Stop the client in all test cases
Co-authored-by: Germain <germains@element.io>