Skip to content

Commit

Permalink
If a room name changes, the subtitle of all open rooms should change …
Browse files Browse the repository at this point in the history
…too (#951)

* passing pubOpts as seperate param

* clean up

* clean up

* style

* name change realtime

* comment
  • Loading branch information
kriscfoster authored Jul 19, 2018
1 parent f78159d commit 7830470
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions db/model/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ module.exports = function room(seq, dataTypes) {
}
}

// Note: We should delete the socket.io namespace for the old room name
if (instance.changed('name')) {
if (instance.active) {
return realTime.publishObject(instance.toJSON(), roomEventNames.upd,
null, null, pubOpts);
}
}

if (instance.changed('active')) {
if (instance.active) {
return realTime.publishObject(instance.toJSON(), roomEventNames.add,
Expand Down
11 changes: 10 additions & 1 deletion view/rooms/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const BOT_REQ_HEADERS = {
let _io;
let _user;
let _roomName;
let _roomTypeName;
let _isActive;
let _movingContent;
let _botsLayout;
Expand Down Expand Up @@ -700,6 +701,13 @@ function setupSocketIOClient(bots) {
const room = eventData[settingsChangedEventName];
if (room.id === parseInt(ROOM_ID, 10)) {
debugMessage('Setting Changed', room);

if (_roomName !== room.name) {
_roomName = room.name;
const subTitle = `${_roomName} - ${_roomTypeName}`;
uPage.setSubtitle(subTitle);
}

Object.keys(botInfo).forEach((key) => {
createIframeEvent(roomChannel, room, botInfo, key);
});
Expand Down Expand Up @@ -956,7 +964,8 @@ window.onload = () => {
return u.getPromiseWithUrl(GET_ROOMTYPES + '/' + response.type);
})
.then((res) => {
const subTitle = `${_roomName} - ${res.body.name}`;
_roomTypeName = res.body.name;
const subTitle = `${_roomName} - ${_roomTypeName}`;
uPage.setSubtitle(subTitle);
document.title = subTitle;
let layoutCookie =
Expand Down

0 comments on commit 7830470

Please sign in to comment.