Merge pull request #227 from matrix-org/matthew/fix-notif-spam
Correctly fix notif spam after logout/login
This commit is contained in:
commit
9dcdf0ae51
2 changed files with 18 additions and 15 deletions
|
@ -103,6 +103,7 @@ var Notifier = {
|
||||||
MatrixClientPeg.get().on('Room.timeline', this.boundOnRoomTimeline);
|
MatrixClientPeg.get().on('Room.timeline', this.boundOnRoomTimeline);
|
||||||
MatrixClientPeg.get().on("sync", this.boundOnSyncStateChange);
|
MatrixClientPeg.get().on("sync", this.boundOnSyncStateChange);
|
||||||
this.toolbarHidden = false;
|
this.toolbarHidden = false;
|
||||||
|
this.isPrepared = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
stop: function() {
|
stop: function() {
|
||||||
|
@ -110,6 +111,7 @@ var Notifier = {
|
||||||
MatrixClientPeg.get().removeListener('Room.timeline', this.boundOnRoomTimeline);
|
MatrixClientPeg.get().removeListener('Room.timeline', this.boundOnRoomTimeline);
|
||||||
MatrixClientPeg.get().removeListener('sync', this.boundOnSyncStateChange);
|
MatrixClientPeg.get().removeListener('sync', this.boundOnSyncStateChange);
|
||||||
}
|
}
|
||||||
|
this.isPrepared = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
supportsDesktopNotifications: function() {
|
supportsDesktopNotifications: function() {
|
||||||
|
@ -203,6 +205,7 @@ var Notifier = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onSyncStateChange: function(state) {
|
onSyncStateChange: function(state) {
|
||||||
|
console.log("sync state change: " + state);
|
||||||
if (state === "PREPARED" || state === "SYNCING") {
|
if (state === "PREPARED" || state === "SYNCING") {
|
||||||
this.isPrepared = true;
|
this.isPrepared = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,6 +236,17 @@ module.exports = React.createClass({
|
||||||
var self = this;
|
var self = this;
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case 'logout':
|
case 'logout':
|
||||||
|
var guestCreds;
|
||||||
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
|
guestCreds = { // stash our guest creds so we can backout if needed
|
||||||
|
userId: MatrixClientPeg.get().credentials.userId,
|
||||||
|
accessToken: MatrixClientPeg.get().getAccessToken(),
|
||||||
|
homeserverUrl: MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
|
identityServerUrl: MatrixClientPeg.get().getIdentityServerUrl(),
|
||||||
|
guest: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (window.localStorage) {
|
if (window.localStorage) {
|
||||||
var hsUrl = this.getCurrentHsUrl();
|
var hsUrl = this.getCurrentHsUrl();
|
||||||
var isUrl = this.getCurrentIsUrl();
|
var isUrl = this.getCurrentIsUrl();
|
||||||
|
@ -255,7 +266,8 @@ module.exports = React.createClass({
|
||||||
this.notifyNewScreen('login');
|
this.notifyNewScreen('login');
|
||||||
this.replaceState({
|
this.replaceState({
|
||||||
logged_in: false,
|
logged_in: false,
|
||||||
ready: false
|
ready: false,
|
||||||
|
guestCreds: guestCreds,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'start_registration':
|
case 'start_registration':
|
||||||
|
@ -281,7 +293,8 @@ module.exports = React.createClass({
|
||||||
case 'start_login':
|
case 'start_login':
|
||||||
if (this.state.logged_in) return;
|
if (this.state.logged_in) return;
|
||||||
this.replaceState({
|
this.replaceState({
|
||||||
screen: 'login'
|
screen: 'login',
|
||||||
|
guestCreds: this.state.guestCreds,
|
||||||
});
|
});
|
||||||
this.notifyNewScreen('login');
|
this.notifyNewScreen('login');
|
||||||
break;
|
break;
|
||||||
|
@ -290,19 +303,6 @@ module.exports = React.createClass({
|
||||||
screen: 'post_registration'
|
screen: 'post_registration'
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'start_login_from_guest':
|
|
||||||
this.replaceState({
|
|
||||||
screen: 'login',
|
|
||||||
guestCreds: { // stash our guest creds so we can backout if needed
|
|
||||||
userId: MatrixClientPeg.get().credentials.userId,
|
|
||||||
accessToken: MatrixClientPeg.get().getAccessToken(),
|
|
||||||
homeserverUrl: MatrixClientPeg.get().getHomeserverUrl(),
|
|
||||||
identityServerUrl: MatrixClientPeg.get().getIdentityServerUrl(),
|
|
||||||
guest: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.notifyNewScreen('login');
|
|
||||||
break;
|
|
||||||
case 'start_upgrade_registration':
|
case 'start_upgrade_registration':
|
||||||
this.replaceState({
|
this.replaceState({
|
||||||
screen: "register",
|
screen: "register",
|
||||||
|
|
Loading…
Reference in a new issue