matrix-org / matrix-js-sdk

Matrix Client-Server SDK for JavaScript
Apache License 2.0
1.49k stars 577 forks source link

Fetch capabilities in the background #4246

Closed dbkr closed 1 week ago

dbkr commented 1 week ago

& keep them up to date.

I've elected to change the interface here and split it into two functions rather than re-use the same one. That way, the cached one doesn't need to return a promise. This does make it a BREAKING CHANGE. I've given both functions different names so it's obvious that they're different. It's a trivial code update so I don't really think its worth having a backwards compat function?

It also splits some code out of client.ts(!)

Any of the tests that use runAllTimers() needed replacing with something that would just run the ones they need, since this works by continually setting a timer to keep the capabilities up to date. I don't think runAllTimers() is a sensible thing to use unless you're testing a small piece of code where you know all the timers it's setting.

Checklist

dbkr commented 1 week ago

Perhaps, but I don't think it would be useful to us right now, particularly? Especially given it will only update every 6 hours, normally. I'd be inclined to keep any extra complexity out until its needed.