* Update src with globalThis
* Update spec with globalThis
* Replace in more spec/ places
* More changes to src/
* Add a linter rule for global
* Prettify
* lint
https://github.com/dumbmatter/fakeIndexedDB/pull/93 causes a bunch
of tests to start failing because the fake timers need running in
order for fake indexeddb to work. It also seems to cause failures
to bleed between tests somehow if fake timers are enabled/disabled.
This keeps all the fake timer tests in one suite and all the others
in another, which appears to work.
This should allow https://github.com/matrix-org/matrix-js-sdk/pull/4224
to be merged.
* 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>