Make isEnabled
an instance variable
This commit is contained in:
parent
d6ff5af843
commit
a61f2939fd
1 changed files with 6 additions and 8 deletions
|
@ -14,10 +14,9 @@
|
||||||
MESSAGE : 'message'
|
MESSAGE : 'message'
|
||||||
};
|
};
|
||||||
|
|
||||||
let isEnabled = false;
|
|
||||||
|
|
||||||
Whisper.Notifications = new (Backbone.Collection.extend({
|
Whisper.Notifications = new (Backbone.Collection.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
this.isEnabled = false;
|
||||||
this.on('add', this.update);
|
this.on('add', this.update);
|
||||||
this.on('remove', this.onRemove);
|
this.on('remove', this.onRemove);
|
||||||
},
|
},
|
||||||
|
@ -35,12 +34,12 @@
|
||||||
console.log(
|
console.log(
|
||||||
'Update notifications:',
|
'Update notifications:',
|
||||||
'isFocused:', isFocused,
|
'isFocused:', isFocused,
|
||||||
'isEnabled:', isEnabled,
|
'isEnabled:', this.isEnabled,
|
||||||
'numNotifications:', numNotifications,
|
'numNotifications:', numNotifications,
|
||||||
'shouldPlayNotificationSound:', shouldPlayNotificationSound
|
'shouldPlayNotificationSound:', shouldPlayNotificationSound
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isEnabled) {
|
if (!this.isEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,15 +130,14 @@
|
||||||
this.reset([]);
|
this.reset([]);
|
||||||
},
|
},
|
||||||
enable: function() {
|
enable: function() {
|
||||||
const needUpdate = !isEnabled;
|
const needUpdate = !this.isEnabled;
|
||||||
isEnabled = true;
|
this.isEnabled = true;
|
||||||
if (needUpdate) {
|
if (needUpdate) {
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
disable: function() {
|
disable: function() {
|
||||||
isEnabled = false;
|
this.isEnabled = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
}))();
|
}))();
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue