Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1127 from matrix-org/t3chguy/reset_favicon_on_logout
Browse files Browse the repository at this point in the history
reset page subtitle and favicon on_logged_out
  • Loading branch information
dbkr committed Jun 21, 2017
2 parents a7ca8ae + a5fffe4 commit 72e73c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/BasePlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import dis from './dispatcher';

/**
* Base class for classes that provide platform-specific functionality
* eg. Setting an application badge or displaying notifications
Expand All @@ -27,6 +29,16 @@ export default class BasePlatform {
constructor() {
this.notificationCount = 0;
this.errorDidOccur = false;

dis.register(this._onAction.bind(this));
}

_onAction(payload: Object) {
switch (payload.action) {
case 'on_logged_out':
this.setNotificationCount(0);
break;
}
}

// Used primarily for Analytics
Expand Down
13 changes: 9 additions & 4 deletions src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ module.exports = React.createClass({
page_type: PageTypes.RoomDirectory,
});
this._teamToken = null;
this._setPageSubtitle();
},

/**
Expand Down Expand Up @@ -1323,6 +1324,10 @@ module.exports = React.createClass({
});
},

_setPageSubtitle: function(subtitle='') {
document.title = `Riot ${subtitle}`;
},

updateStatusIndicator: function(state, prevState) {
let notifCount = 0;

Expand All @@ -1343,15 +1348,15 @@ module.exports = React.createClass({
PlatformPeg.get().setNotificationCount(notifCount);
}

let title = "Riot ";
let subtitle = '';
if (state === "ERROR") {
title += `[${_t("Offline")}] `;
subtitle += `[${_t("Offline")}] `;
}
if (notifCount > 0) {
title += `[${notifCount}]`;
subtitle += `[${notifCount}]`;
}

document.title = title;
this._setPageSubtitle(subtitle);
},

onUserSettingsClose: function() {
Expand Down

0 comments on commit 72e73c0

Please sign in to comment.