From 37782768f7209fc3d40949b2499e34bedde34598 Mon Sep 17 00:00:00 2001 From: deardrops Date: Tue, 23 May 2017 18:30:53 +0800 Subject: [PATCH] fix bugs of renaming room recovery previous room name when fail to rename room add `onblur` listener to #room-name element --- .gitignore | 3 ++- RoomManager.js | 10 ++++++++++ webxoss-client | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bc67cdb..27f29d8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules trash .DS_Store *.sublime-* -yarn.lock \ No newline at end of file +yarn.lock +.vscode/ \ No newline at end of file diff --git a/RoomManager.js b/RoomManager.js index f85bb76..61062ea 100644 --- a/RoomManager.js +++ b/RoomManager.js @@ -218,16 +218,26 @@ RoomManager.prototype.renameRoom = function (client,cfg) { } var oldRoomName = client.room.name; var newRoomName = cfg.roomName; + if (newRoomName === oldRoomName) { + return; + } if (!errMsg) { errMsg = this.checkRoomName(newRoomName); } var room; + if (!errMsg) { + if (newRoomName in this.roomMap) { + errMsg = 'ROOM_ALREADY_EXISTS'; + client.room.update(); + } + } if (!errMsg) { room = this.roomMap[oldRoomName]; if (!room) { errMsg = 'ROOM_DOES_NOT_EXIST'; } else if (client.getPosition() !== 'host') { errMsg = 'YOU_ARE_NOT_ROOM_HOST'; + client.room.update(); } } if (errMsg) { diff --git a/webxoss-client b/webxoss-client index 51a710f..36727dd 160000 --- a/webxoss-client +++ b/webxoss-client @@ -1 +1 @@ -Subproject commit 51a710f84c2931e55ca71009ad469468b5662863 +Subproject commit 36727dd62e19545ca9a0abcc25124e7858c788aa