mirror of https://github.com/vector-im/riot-web
Merge pull request #227 from matrix-org/matthew/fix-notif-spam
Correctly fix notif spam after logout/loginpull/21833/head
commit
9dcdf0ae51
|
@ -103,6 +103,7 @@ var Notifier = {
|
|||
MatrixClientPeg.get().on('Room.timeline', this.boundOnRoomTimeline);
|
||||
MatrixClientPeg.get().on("sync", this.boundOnSyncStateChange);
|
||||
this.toolbarHidden = false;
|
||||
this.isPrepared = false;
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
|
@ -110,6 +111,7 @@ var Notifier = {
|
|||
MatrixClientPeg.get().removeListener('Room.timeline', this.boundOnRoomTimeline);
|
||||
MatrixClientPeg.get().removeListener('sync', this.boundOnSyncStateChange);
|
||||
}
|
||||
this.isPrepared = false;
|
||||
},
|
||||
|
||||
supportsDesktopNotifications: function() {
|
||||
|
@ -203,6 +205,7 @@ var Notifier = {
|
|||
},
|
||||
|
||||
onSyncStateChange: function(state) {
|
||||
console.log("sync state change: " + state);
|
||||
if (state === "PREPARED" || state === "SYNCING") {
|
||||
this.isPrepared = true;
|
||||
}
|
||||
|
|
|
@ -236,6 +236,17 @@ module.exports = React.createClass({
|
|||
var self = this;
|
||||
switch (payload.action) {
|
||||
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) {
|
||||
var hsUrl = this.getCurrentHsUrl();
|
||||
var isUrl = this.getCurrentIsUrl();
|
||||
|
@ -255,7 +266,8 @@ module.exports = React.createClass({
|
|||
this.notifyNewScreen('login');
|
||||
this.replaceState({
|
||||
logged_in: false,
|
||||
ready: false
|
||||
ready: false,
|
||||
guestCreds: guestCreds,
|
||||
});
|
||||
break;
|
||||
case 'start_registration':
|
||||
|
@ -281,7 +293,8 @@ module.exports = React.createClass({
|
|||
case 'start_login':
|
||||
if (this.state.logged_in) return;
|
||||
this.replaceState({
|
||||
screen: 'login'
|
||||
screen: 'login',
|
||||
guestCreds: this.state.guestCreds,
|
||||
});
|
||||
this.notifyNewScreen('login');
|
||||
break;
|
||||
|
@ -290,19 +303,6 @@ module.exports = React.createClass({
|
|||
screen: 'post_registration'
|
||||
});
|
||||
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':
|
||||
this.replaceState({
|
||||
screen: "register",
|
||||
|
|
Loading…
Reference in New Issue