From 5460b0f5b2fb963d5a7c44a9fbf1df177ae33be1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jun 2017 15:31:12 +0100 Subject: [PATCH 1/4] reset page subtitle on_logged_out Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index ab937c07ac..21c76fb70f 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -968,6 +968,7 @@ module.exports = React.createClass({ * Called when the session is logged out */ _onLoggedOut: function() { + this._setPageSubtitle(); this.notifyNewScreen('login'); this.setStateForNewScreen({ loggedIn: false, @@ -1267,6 +1268,10 @@ module.exports = React.createClass({ }); }, + _setPageSubtitle: function(subtitle='') { + document.title = `Riot ${subtitle}`; + }, + updateStatusIndicator: function(state, prevState) { let notifCount = 0; @@ -1287,15 +1292,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() { From b712a15a149b95b874c4922250c9c79e48d7aca4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jun 2017 16:15:42 +0100 Subject: [PATCH 2/4] move in case it is racey ---- somehow? Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 108a94cba2..17df3172df 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -993,7 +993,6 @@ module.exports = React.createClass({ * Called when the session is logged out */ _onLoggedOut: function() { - this._setPageSubtitle(); this.notifyNewScreen('login'); this.setStateForNewView({ view: VIEWS.LOGIN, @@ -1004,6 +1003,7 @@ module.exports = React.createClass({ page_type: PageTypes.RoomDirectory, }); this._teamToken = null; + this._setPageSubtitle(); }, /** From 36d10e7bb68bfb38aac13d25184f1244e3606d6d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jun 2017 18:47:35 +0100 Subject: [PATCH 3/4] move favicon reset stuff here where its more general Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/BasePlatform.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index d0d8e0c74e..e45f4a57b9 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 From a5fffe4afa8367b6522036eb7a144a5ad506157a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@googlemail.com> Date: Tue, 20 Jun 2017 20:15:25 +0100 Subject: [PATCH 4/4] fix ambiguity --- src/BasePlatform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index e45f4a57b9..a920479823 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -17,7 +17,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import dis from 'dispatcher'; +import dis from './dispatcher'; /** * Base class for classes that provide platform-specific functionality