Run all room leaving behaviour through a single function

Fixes https://github.com/vector-im/element-web/issues/14999
Fixes https://github.com/vector-im/element-web/issues/10380

We were failing to handle errors when `/part`ing a room, though the leave room button was fine. This runs both the button and command through the same function for handling, including the 'view next room' behaviour.
This commit is contained in:
Travis Ralston 2020-08-19 19:21:40 -06:00
parent c9d98a1d19
commit e0b8343088
4 changed files with 78 additions and 49 deletions

View file

@ -43,7 +43,7 @@ import SdkConfig from "./SdkConfig";
import { ensureDMExists } from "./createRoom";
import { ViewUserPayload } from "./dispatcher/payloads/ViewUserPayload";
import { Action } from "./dispatcher/actions";
import { EffectiveMembership, getEffectiveMembership } from "./utils/membership";
import { EffectiveMembership, getEffectiveMembership, leaveRoomBehaviour } from "./utils/membership";
// XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816
interface HTMLInputEvent extends Event {
@ -601,11 +601,7 @@ export const Commands = [
}
if (!targetRoomId) targetRoomId = roomId;
return success(
cli.leaveRoomChain(targetRoomId).then(function() {
dis.dispatch({action: 'view_next_room'});
}),
);
return success(leaveRoomBehaviour(targetRoomId));
},
category: CommandCategories.actions,
}),