From 37782768f7209fc3d40949b2499e34bedde34598 Mon Sep 17 00:00:00 2001 From: deardrops Date: Tue, 23 May 2017 18:30:53 +0800 Subject: [PATCH 1/2] 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 From 39d743b77c6019f98bddccfc5669708291a15b2b Mon Sep 17 00:00:00 2001 From: deardrops Date: Mon, 29 May 2017 10:09:37 +0800 Subject: [PATCH 2/2] limit rename room by same name --- RoomManager.js | 2 +- webxoss-client | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RoomManager.js b/RoomManager.js index 61062ea..95e9659 100644 --- a/RoomManager.js +++ b/RoomManager.js @@ -245,7 +245,7 @@ RoomManager.prototype.renameRoom = function (client,cfg) { return; } - room.name = newRoomName; + room.name = newRoomName; // update client.room.name renameProperty(this.roomMap, oldRoomName, newRoomName); room.update(); this.updateRoomList(); diff --git a/webxoss-client b/webxoss-client index 36727dd..05f5058 160000 --- a/webxoss-client +++ b/webxoss-client @@ -1 +1 @@ -Subproject commit 36727dd62e19545ca9a0abcc25124e7858c788aa +Subproject commit 05f50588feefab6b79887bab0fd473a1063e22b4