From e5b3326703eab2f666f5d7488c2fcfd2f1589927 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Thu, 11 Jun 2015 18:29:40 -0400 Subject: [PATCH] Make sure Staff and Upper Staff are first This is a dumb hack to make sure that Staff and Upper Staff are to the left of any autojoined rooms. They're excluded from autojoin, so without this, they would be all the way on the right. --- js/client-mainmenu.js | 1 + js/client.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index ac06a58d8..fb4fb5a93 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -313,6 +313,7 @@ var handlerRoom = app.curSideRoom; if (!handlerRoom) { for (var roomid in app.rooms) { + if (!app.rooms[roomid]) continue; if (!app.rooms[roomid].handleTabComplete) continue; handlerRoom = app.rooms[roomid]; break; diff --git a/js/client.js b/js/client.js index e94b31f6c..ae56ac7b9 100644 --- a/js/client.js +++ b/js/client.js @@ -303,6 +303,9 @@ this.topbar = new Topbar({el: $('#header')}); this.addRoom(''); if (!this.down && $(window).width() >= 916) { + // make sure staff and upperstaff are first in room list + this.rooms.staff = undefined; + this.rooms.upperstaff = undefined; if (document.location.hostname === 'play.pokemonshowdown.com') { this.addRoom('rooms', null, true); var autojoin = (Tools.prefs('autojoin') || ''); @@ -1372,7 +1375,7 @@ // no room for this room } else if (!this.sideRoom) { for (var i in this.rooms) { - if (this.rooms[i].isSideRoom) { + if (this.rooms[i] && this.rooms[i].isSideRoom) { this.sideRoom = this.rooms[i]; } } @@ -1581,6 +1584,7 @@ var notificationCount = 0; for (var id in app.rooms) { + if (!app.rooms[id]) continue; if (app.rooms[id].notifications) notificationCount++; if (!id || id === 'teambuilder' || id === 'ladder') continue; var room = app.rooms[id]; @@ -2717,6 +2721,7 @@ for (var id in app.rooms) { if (!id || id === 'teambuilder' || id === 'ladder') continue; var room = app.rooms[id]; + if (!room) continue; var name = ' '+id+''; if (id === 'lobby') name = ' Lobby'; if (id.substr(0,7) === 'battle-') {