Merge pull request #240 from mebjas/develop-notif
Save a preference in local settings to record when the user has hidden the notifications warning bar.
This commit is contained in:
commit
d7f8017b91
1 changed files with 27 additions and 21 deletions
|
@ -132,30 +132,26 @@ var Notifier = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(enable) {
|
if (enable) {
|
||||||
if (!this.havePermission()) {
|
// Attempt to get permission from user
|
||||||
global.Notification.requestPermission(function() {
|
global.Notification.requestPermission(function(result) {
|
||||||
if (callback) {
|
if (result !== 'granted') {
|
||||||
callback();
|
// The permission request was dismissed or denied
|
||||||
dis.dispatch({
|
return;
|
||||||
action: "notifier_enabled",
|
}
|
||||||
value: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!global.localStorage) return;
|
if (global.localStorage) {
|
||||||
global.localStorage.setItem('notifications_enabled', 'true');
|
global.localStorage.setItem('notifications_enabled', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
if (this.havePermission) {
|
if (callback) callback();
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "notifier_enabled",
|
action: "notifier_enabled",
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
this.setToolbarHidden(false);
|
||||||
else {
|
} else {
|
||||||
if (!global.localStorage) return;
|
if (!global.localStorage) return;
|
||||||
global.localStorage.setItem('notifications_enabled', 'false');
|
global.localStorage.setItem('notifications_enabled', 'false');
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
|
@ -163,8 +159,6 @@ var Notifier = {
|
||||||
value: false
|
value: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setToolbarHidden(false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isEnabled: function() {
|
isEnabled: function() {
|
||||||
|
@ -192,15 +186,27 @@ var Notifier = {
|
||||||
return enabled === 'true';
|
return enabled === 'true';
|
||||||
},
|
},
|
||||||
|
|
||||||
setToolbarHidden: function(hidden) {
|
setToolbarHidden: function(hidden, persistent = true) {
|
||||||
this.toolbarHidden = hidden;
|
this.toolbarHidden = hidden;
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "notifier_enabled",
|
action: "notifier_enabled",
|
||||||
value: this.isEnabled()
|
value: this.isEnabled()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// update the info to localStorage for persistent settings
|
||||||
|
if (persistent && global.localStorage) {
|
||||||
|
global.localStorage.setItem('notifications_hidden', hidden);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
isToolbarHidden: function() {
|
isToolbarHidden: function() {
|
||||||
|
// Check localStorage for any such meta data
|
||||||
|
if (global.localStorage) {
|
||||||
|
if (global.localStorage.getItem('notifications_hidden') === 'true') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this.toolbarHidden;
|
return this.toolbarHidden;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue