mirror of
https://github.com/webxoss/webxoss-core.git
synced 2025-01-18 19:56:02 +01:00
Merge pull request #50 from Deardrops/fix/rename-room
fix bugs of renaming room
This commit is contained in:
commit
a3670d981a
3 changed files with 14 additions and 3 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -2,4 +2,5 @@ node_modules
|
|||
trash
|
||||
.DS_Store
|
||||
*.sublime-*
|
||||
yarn.lock
|
||||
yarn.lock
|
||||
.vscode/
|
|
@ -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) {
|
||||
|
@ -235,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();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 51a710f84c2931e55ca71009ad469468b5662863
|
||||
Subproject commit 05f50588feefab6b79887bab0fd473a1063e22b4
|
Loading…
Reference in a new issue