Support dynamic room predecessors in BreadcrumbsStore (#10295)
* Tests for BreadcrumbsStore.meetsRoomRequirements * Tests for appending rooms to BreadcrumbsStore * Support dynamic room predecessors in BreadcrumbsStore
This commit is contained in:
parent
bee4759208
commit
4ee57a36e0
2 changed files with 221 additions and 2 deletions
|
@ -65,9 +65,17 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
|
|||
return !!this.state.enabled && this.meetsRoomRequirement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we have enough rooms to justify showing the breadcrumbs?
|
||||
* (Or is the labs feature enabled?)
|
||||
*
|
||||
* @returns true if there are at least 20 visible rooms or
|
||||
* feature_breadcrumbs_v2 is enabled.
|
||||
*/
|
||||
public get meetsRoomRequirement(): boolean {
|
||||
if (SettingsStore.getValue("feature_breadcrumbs_v2")) return true;
|
||||
return this.matrixClient?.getVisibleRooms().length >= 20;
|
||||
const msc3946ProcessDynamicPredecessor = SettingsStore.getValue("feature_dynamic_room_predecessors");
|
||||
return this.matrixClient?.getVisibleRooms(msc3946ProcessDynamicPredecessor).length >= 20;
|
||||
}
|
||||
|
||||
protected async onAction(payload: SettingUpdatedPayload | ViewRoomPayload | JoinRoomPayload): Promise<void> {
|
||||
|
@ -138,10 +146,11 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
|
|||
private async appendRoom(room: Room): Promise<void> {
|
||||
let updated = false;
|
||||
const rooms = (this.state.rooms || []).slice(); // cheap clone
|
||||
const msc3946ProcessDynamicPredecessor = SettingsStore.getValue("feature_dynamic_room_predecessors");
|
||||
|
||||
// If the room is upgraded, use that room instead. We'll also splice out
|
||||
// any children of the room.
|
||||
const history = this.matrixClient.getRoomUpgradeHistory(room.roomId);
|
||||
const history = this.matrixClient.getRoomUpgradeHistory(room.roomId, false, msc3946ProcessDynamicPredecessor);
|
||||
if (history.length > 1) {
|
||||
room = history[history.length - 1]; // Last room is most recent in history
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue