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 #777 from matrix-org/dbkr/fix_notifs_on_refresh
Browse files Browse the repository at this point in the history
Don't re-notify about messages on browser refresh
  • Loading branch information
dbkr committed Mar 28, 2017
2 parents 91d1064 + 4587b5f commit e90897d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var Notifier = {
MatrixClientPeg.get().on("Room.receipt", this.boundOnRoomReceipt);
MatrixClientPeg.get().on("sync", this.boundOnSyncStateChange);
this.toolbarHidden = false;
this.isPrepared = false;
this.isSyncing = false;
},

stop: function() {
Expand All @@ -107,7 +107,7 @@ var Notifier = {
MatrixClientPeg.get().removeListener("Room.receipt", this.boundOnRoomReceipt);
MatrixClientPeg.get().removeListener('sync', this.boundOnSyncStateChange);
}
this.isPrepared = false;
this.isSyncing = false;
},

supportsDesktopNotifications: function() {
Expand Down Expand Up @@ -213,18 +213,18 @@ var Notifier = {
},

onSyncStateChange: function(state) {
if (state === "PREPARED" || state === "SYNCING") {
this.isPrepared = true;
if (state === "SYNCING") {
this.isSyncing = true;
}
else if (state === "STOPPED" || state === "ERROR") {
this.isPrepared = false;
this.isSyncing = false;
}
},

onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) {
if (toStartOfTimeline) return;
if (!room) return;
if (!this.isPrepared) return; // don't alert for any messages initially
if (!this.isSyncing) return; // don't alert for any messages initially
if (ev.sender && ev.sender.userId == MatrixClientPeg.get().credentials.userId) return;
if (data.timeline.getTimelineSet() !== room.getUnfilteredTimelineSet()) return;

Expand Down

0 comments on commit e90897d

Please sign in to comment.