-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch capabilities in the background #4246
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4854903
Fetch capabilities in the background
dbkr 919d725
Add missed await
dbkr 3aa37a9
Replace some more runAllTimers
dbkr d88e60a
Remove double comment
dbkr a759454
Typo
dbkr fad022b
Add a method back that will fetch capabilities if they're not already…
dbkr 382cae7
Add tests
dbkr 000b02f
Catch exception here too
dbkr 3e8c3c0
Add test for room version code
dbkr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ import { | |
RelationType, | ||
UNSIGNED_THREAD_ID_FIELD, | ||
} from "../@types/event"; | ||
import { IRoomVersionsCapability, MatrixClient, PendingEventOrdering, RoomVersionStability } from "../client"; | ||
import { MatrixClient, PendingEventOrdering } from "../client"; | ||
import { GuestAccess, HistoryVisibility, JoinRule, ResizeMethod } from "../@types/partials"; | ||
import { Filter, IFilterDefinition } from "../filter"; | ||
import { RoomState, RoomStateEvent, RoomStateEventHandlerMap } from "./room-state"; | ||
|
@@ -70,6 +70,7 @@ import { RoomReceipts } from "./room-receipts"; | |
import { compareEventOrdering } from "./compare-event-ordering"; | ||
import * as utils from "../utils"; | ||
import { KnownMembership, Membership } from "../@types/membership"; | ||
import { IRoomVersionsCapability, RoomVersionStability } from "../serverCapabilities"; | ||
|
||
// These constants are used as sane defaults when the homeserver doesn't support | ||
// the m.room_versions capability. In practice, KNOWN_SAFE_ROOM_VERSION should be | ||
|
@@ -611,8 +612,8 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> { | |
* Resolves to the version the room should be upgraded to. | ||
*/ | ||
public async getRecommendedVersion(): Promise<IRecommendedVersion> { | ||
const capabilities = await this.client.getCapabilities(); | ||
let versionCap = capabilities["m.room_versions"]; | ||
const capabilities = this.client.getCachedCapabilities(); | ||
let versionCap = (capabilities ?? {})["m.room_versions"]; | ||
if (!versionCap) { | ||
versionCap = { | ||
default: KNOWN_SAFE_ROOM_VERSION, | ||
|
@@ -636,7 +637,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> { | |
"to be supporting a newer room version we don't know about.", | ||
); | ||
|
||
const caps = await this.client.getCapabilities(true); | ||
const caps = await this.client.fetchCapabilities(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would throw here now? instead of returning a default value? Would impact the react-sdk? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I forgot to catch the exception here actually. |
||
versionCap = caps["m.room_versions"]; | ||
if (!versionCap) { | ||
logger.warn("No room version capability - assuming upgrade required."); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if
getRecommendedVersion
is called before the first capabilities response comes down?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I've put back a function that does the same as before.