mirror of https://github.com/vector-im/riot-web
				
				
				
			Merge pull request #2818 from matrix-org/travis/leave-room-chain
Use leaveRoomChain when leaving a roompull/21833/head
						commit
						a9ea74610a
					
				| 
						 | 
				
			
			@ -431,7 +431,7 @@ export const CommandMap = {
 | 
			
		|||
 | 
			
		||||
            if (!targetRoomId) targetRoomId = roomId;
 | 
			
		||||
            return success(
 | 
			
		||||
                cli.leave(targetRoomId).then(function() {
 | 
			
		||||
                cli.leaveRoomChain(targetRoomId).then(function() {
 | 
			
		||||
                    dis.dispatch({action: 'view_next_room'});
 | 
			
		||||
                }),
 | 
			
		||||
            );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1058,23 +1058,23 @@ export default React.createClass({
 | 
			
		|||
            button: _t("Leave"),
 | 
			
		||||
            onFinished: (shouldLeave) => {
 | 
			
		||||
                if (shouldLeave) {
 | 
			
		||||
                    const d = MatrixClientPeg.get().leave(roomId);
 | 
			
		||||
                    const d = MatrixClientPeg.get().leaveRoomChain(roomId);
 | 
			
		||||
 | 
			
		||||
                    // FIXME: controller shouldn't be loading a view :(
 | 
			
		||||
                    const Loader = sdk.getComponent("elements.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();
 | 
			
		||||
                        console.error("Failed to leave room " + roomId + " " + err);
 | 
			
		||||
 | 
			
		||||
                        for (const leftRoomId of Object.keys(errors)) {
 | 
			
		||||
                            const err = errors[leftRoomId];
 | 
			
		||||
                            if (!err) continue;
 | 
			
		||||
 | 
			
		||||
                            console.error("Failed to leave room " + leftRoomId + " " + err);
 | 
			
		||||
                            let title = _t("Failed to leave room");
 | 
			
		||||
                            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");
 | 
			
		||||
                                message = _t(
 | 
			
		||||
                                    "This room is used for important messages from the Homeserver, " +
 | 
			
		||||
| 
						 | 
				
			
			@ -1087,6 +1087,20 @@ export default React.createClass({
 | 
			
		|||
                                title: title,
 | 
			
		||||
                                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: _t("Failed to leave room"),
 | 
			
		||||
                            description: _t("Unknown error"),
 | 
			
		||||
                        });
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue