mirror of https://github.com/vector-im/riot-web
Use leaveRoomChain when leaving a room
Requires https://github.com/matrix-org/matrix-js-sdk/pull/868 Fixes https://github.com/vector-im/riot-web/issues/8539 We don't need to use leaveRoomChain when rejecting invites because we won't have the references needed. This leaves the couple spots where we do actually leave a room, and use the new function for that.pull/21833/head
parent
68997f9652
commit
a34a8bb425
|
@ -431,7 +431,7 @@ export const CommandMap = {
|
||||||
|
|
||||||
if (!targetRoomId) targetRoomId = roomId;
|
if (!targetRoomId) targetRoomId = roomId;
|
||||||
return success(
|
return success(
|
||||||
cli.leave(targetRoomId).then(function() {
|
cli.leaveRoomChain(targetRoomId).then(function() {
|
||||||
dis.dispatch({action: 'view_next_room'});
|
dis.dispatch({action: 'view_next_room'});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1058,23 +1058,22 @@ export default React.createClass({
|
||||||
button: _t("Leave"),
|
button: _t("Leave"),
|
||||||
onFinished: (shouldLeave) => {
|
onFinished: (shouldLeave) => {
|
||||||
if (shouldLeave) {
|
if (shouldLeave) {
|
||||||
const d = MatrixClientPeg.get().leave(roomId);
|
const d = MatrixClientPeg.get().leaveRoomChain(roomId);
|
||||||
|
|
||||||
// FIXME: controller shouldn't be loading a view :(
|
// FIXME: controller shouldn't be loading a view :(
|
||||||
const Loader = sdk.getComponent("elements.Spinner");
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner');
|
const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner');
|
||||||
|
|
||||||
d.then(() => {
|
d.then((errors) => {
|
||||||
modal.close();
|
|
||||||
if (this.state.currentRoomId === roomId) {
|
|
||||||
dis.dispatch({action: 'view_next_room'});
|
|
||||||
}
|
|
||||||
}, (err) => {
|
|
||||||
modal.close();
|
modal.close();
|
||||||
|
|
||||||
|
if (errors[roomId]) {
|
||||||
|
// Something went wrong
|
||||||
|
const err = errors[roomId];
|
||||||
console.error("Failed to leave room " + roomId + " " + err);
|
console.error("Failed to leave room " + roomId + " " + err);
|
||||||
let title = _t("Failed to leave room");
|
let title = _t("Failed to leave room");
|
||||||
let message = _t("Server may be unavailable, overloaded, or you hit a bug.");
|
let message = _t("Server may be unavailable, overloaded, or you hit a bug.");
|
||||||
if (err.errcode == 'M_CANNOT_LEAVE_SERVER_NOTICE_ROOM') {
|
if (err.errcode === 'M_CANNOT_LEAVE_SERVER_NOTICE_ROOM') {
|
||||||
title = _t("Can't leave Server Notices room");
|
title = _t("Can't leave Server Notices room");
|
||||||
message = _t(
|
message = _t(
|
||||||
"This room is used for important messages from the Homeserver, " +
|
"This room is used for important messages from the Homeserver, " +
|
||||||
|
@ -1087,6 +1086,20 @@ export default React.createClass({
|
||||||
title: title,
|
title: title,
|
||||||
description: message,
|
description: message,
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.currentRoomId === roomId) {
|
||||||
|
dis.dispatch({action: 'view_next_room'});
|
||||||
|
}
|
||||||
|
}, (err) => {
|
||||||
|
// This should only happen if something went seriously wrong with leaving the chain.
|
||||||
|
modal.close();
|
||||||
|
console.error("Failed to leave room " + roomId + " " + err);
|
||||||
|
Modal.createTrackedDialog('Failed to leave room', '', ErrorDialog, {
|
||||||
|
title: title,
|
||||||
|
description: _t("Unknown error"),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue