diff --git a/src/BasePlatform.js b/src/BasePlatform.js index d0d8e0c74e..a920479823 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -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 @@ -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 diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 4b85ae1722..019446ae84 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -999,6 +999,7 @@ module.exports = React.createClass({ page_type: PageTypes.RoomDirectory, }); this._teamToken = null; + this._setPageSubtitle(); }, /** @@ -1323,6 +1324,10 @@ module.exports = React.createClass({ }); }, + _setPageSubtitle: function(subtitle='') { + document.title = `Riot ${subtitle}`; + }, + updateStatusIndicator: function(state, prevState) { let notifCount = 0; @@ -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() {