= React.forwardRef(({ mxEvent, getRelati
);
};
+ let map: JSX.Element;
+ if (displayStatus === BeaconDisplayStatus.Active && !isMapDisplayError) {
+ map = ;
+ } else if (isMapDisplayError) {
+ map = ;
+ } else {
+ map = ;
+ }
+
return (
- { (displayStatus === BeaconDisplayStatus.Active && !isMapDisplayError) ?
-
- : isMapDisplayError ?
- :
-
- }
+ { map }
{ isOwnBeacon ?
{
cli.on(UserEvent.LastPresenceTs, this.onUserPresenceChange);
cli.on(UserEvent.Presence, this.onUserPresenceChange);
cli.on(UserEvent.CurrentlyActive, this.onUserPresenceChange);
- // cli.on("Room.timeline", this.onRoomTimeline);
}
componentWillUnmount() {
@@ -199,7 +198,6 @@ export default class MemberList extends React.Component {
// member tile and re-render it. This is more efficient than every tile
// ever attaching their own listener.
const tile = this.refs[user.userId];
- // console.log(`Got presence update for ${user.userId}. hasTile=${!!tile}`);
if (tile) {
this.updateList(); // reorder the membership list
}
@@ -370,14 +368,9 @@ export default class MemberList extends React.Component {
// ...and then alphabetically.
// We could tiebreak instead by "last recently spoken in this room" if we wanted to.
- // console.log(`Comparing userA=${this.memberString(memberA)} userB=${this.memberString(memberB)}`);
-
const userA = memberA.user;
const userB = memberB.user;
- // if (!userA) console.log("!! MISSING USER FOR A-SIDE: " + memberA.name + " !!");
- // if (!userB) console.log("!! MISSING USER FOR B-SIDE: " + memberB.name + " !!");
-
if (!userA && !userB) return 0;
if (userA && !userB) return -1;
if (!userA && userB) return 1;
@@ -393,22 +386,18 @@ export default class MemberList extends React.Component {
const idxA = presenceIndex(userA.currentlyActive ? 'active' : userA.presence);
const idxB = presenceIndex(userB.currentlyActive ? 'active' : userB.presence);
- // console.log(`userA_presenceGroup=${idxA} userB_presenceGroup=${idxB}`);
if (idxA !== idxB) {
- // console.log("Comparing on presence group - returning");
return idxA - idxB;
}
}
// Second by power level
if (memberA.powerLevel !== memberB.powerLevel) {
- // console.log("Comparing on power level - returning");
return memberB.powerLevel - memberA.powerLevel;
}
// Third by last active
if (this.showPresence && userA.getLastActiveTs() !== userB.getLastActiveTs()) {
- // console.log("Comparing on last active timestamp - returning");
return userB.getLastActiveTs() - userA.getLastActiveTs();
}
diff --git a/src/components/views/rooms/RoomSublist.tsx b/src/components/views/rooms/RoomSublist.tsx
index 9f8133d55c..a9d73e218e 100644
--- a/src/components/views/rooms/RoomSublist.tsx
+++ b/src/components/views/rooms/RoomSublist.tsx
@@ -274,7 +274,7 @@ export default class RoomSublist extends React.Component {
};
private onListsUpdated = () => {
- const stateUpdates: IState & any = {}; // &any is to avoid a cast on the initializer
+ const stateUpdates = {} as IState;
const currentRooms = this.state.rooms;
const newRooms = arrayFastClone(RoomListStore.instance.orderedLists[this.props.tagId] || []);
diff --git a/src/components/views/settings/ChangePassword.tsx b/src/components/views/settings/ChangePassword.tsx
index f7c174da3b..edd6a4caac 100644
--- a/src/components/views/settings/ChangePassword.tsx
+++ b/src/components/views/settings/ChangePassword.tsx
@@ -353,13 +353,7 @@ export default class ChangePassword extends React.Component {
}
private allFieldsValid(): boolean {
- const keys = Object.keys(this.state.fieldValid);
- for (let i = 0; i < keys.length; ++i) {
- if (!this.state.fieldValid[keys[i]]) {
- return false;
- }
- }
- return true;
+ return Object.values(this.state.fieldValid).every(Boolean);
}
private findFirstInvalidField(fieldIDs: string[]): Field {
diff --git a/src/components/views/terms/InlineTermsAgreement.tsx b/src/components/views/terms/InlineTermsAgreement.tsx
index 2cca51e670..3507822786 100644
--- a/src/components/views/terms/InlineTermsAgreement.tsx
+++ b/src/components/views/terms/InlineTermsAgreement.tsx
@@ -50,7 +50,7 @@ export default class InlineTermsAgreement extends React.Component {
});
});
});
+
+ describe("/part", () => {
+ it("should part room matching alias if found", async () => {
+ const room1 = new Room("room-id", client, client.getUserId());
+ room1.getCanonicalAlias = jest.fn().mockReturnValue("#foo:bar");
+ const room2 = new Room("other-room", client, client.getUserId());
+ room2.getCanonicalAlias = jest.fn().mockReturnValue("#baz:bar");
+ mocked(client.getRooms).mockReturnValue([room1, room2]);
+
+ const command = getCommand("/part #foo:bar");
+ expect(command.cmd).toBeDefined();
+ expect(command.args).toBeDefined();
+ await command.cmd.run("room-id", null, command.args);
+ expect(client.leaveRoomChain).toHaveBeenCalledWith("room-id", expect.anything());
+ });
+
+ it("should part room matching alt alias if found", async () => {
+ const room1 = new Room("room-id", client, client.getUserId());
+ room1.getAltAliases = jest.fn().mockReturnValue(["#foo:bar"]);
+ const room2 = new Room("other-room", client, client.getUserId());
+ room2.getAltAliases = jest.fn().mockReturnValue(["#baz:bar"]);
+ mocked(client.getRooms).mockReturnValue([room1, room2]);
+
+ const command = getCommand("/part #foo:bar");
+ expect(command.cmd).toBeDefined();
+ expect(command.args).toBeDefined();
+ await command.cmd.run("room-id", null, command.args);
+ expect(client.leaveRoomChain).toHaveBeenCalledWith("room-id", expect.anything());
+ });
+ });
});
diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts
index 85045a6da8..ae7f53865b 100644
--- a/test/test-utils/test-utils.ts
+++ b/test/test-utils/test-utils.ts
@@ -187,6 +187,7 @@ export function createTestClient(): MatrixClient {
} as unknown as MediaHandler),
uploadContent: jest.fn(),
getEventMapper: () => (opts) => new MatrixEvent(opts),
+ leaveRoomChain: jest.fn(roomId => ({ [roomId]: null })),
} as unknown as MatrixClient;
client.reEmitter = new ReEmitter(client);