mirror of https://github.com/vector-im/riot-web
unwanted functions removed, prev functions modified
parent
9b5519e866
commit
8191eaa40b
|
@ -123,28 +123,6 @@ var Notifier = {
|
|||
return global.Notification.permission == 'granted';
|
||||
},
|
||||
|
||||
isPermissionDefault: function() {
|
||||
if (!this.supportsDesktopNotifications()) return false;
|
||||
return global.Notification.permission == 'default';
|
||||
},
|
||||
|
||||
// Function to be used by clients to check weather or not to
|
||||
// show the toolbar.
|
||||
shouldShowToolbar: function() {
|
||||
// Check localStorage for any such meta data
|
||||
if (global.localStorage) {
|
||||
if (global.localStorage.getItem('notifications_hidden') === 'true')
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if permission is granted by any chance.
|
||||
if (this.havePermission()) return false;
|
||||
|
||||
// means the permission is blocked
|
||||
if (!this.isPermissionDefault()) return false;
|
||||
return true;
|
||||
},
|
||||
|
||||
setEnabled: function(enable, callback) {
|
||||
// make sure that we persist the current setting audio_enabled setting
|
||||
// before changing anything
|
||||
|
@ -156,20 +134,10 @@ var Notifier = {
|
|||
|
||||
if(enable) {
|
||||
// Case when we do not have the permission as 'granted'
|
||||
if (this.isPermissionDefault()) {
|
||||
// Attempt to get permission from user
|
||||
var self = this;
|
||||
global.Notification.requestPermission(function(result) {
|
||||
if (result === 'denied') {
|
||||
dis.dispatch({
|
||||
action: "notifier_enabled",
|
||||
value: false
|
||||
});
|
||||
self.setToolbarHidden(true, false);
|
||||
return;
|
||||
}
|
||||
if (result === 'default') {
|
||||
// The permission request was dismissed
|
||||
if (result !== 'granted') {
|
||||
// The permission request was dismissed or denied
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -182,7 +150,6 @@ var Notifier = {
|
|||
if (!global.localStorage) return;
|
||||
global.localStorage.setItem('notifications_enabled', 'true');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!global.localStorage) return;
|
||||
global.localStorage.setItem('notifications_enabled', 'false');
|
||||
|
@ -232,6 +199,13 @@ var Notifier = {
|
|||
},
|
||||
|
||||
isToolbarHidden: function() {
|
||||
// Check localStorage for any such meta data
|
||||
if (global.localStorage) {
|
||||
if (global.localStorage.getItem('notifications_hidden') === 'true') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return this.toolbarHidden;
|
||||
},
|
||||
|
||||
|
|
|
@ -1046,7 +1046,7 @@ module.exports = React.createClass({
|
|||
if (MatrixClientPeg.get().isGuest()) {
|
||||
topBar = <GuestWarningBar />;
|
||||
}
|
||||
else if (Notifier.supportsDesktopNotifications() && Notifier.shouldShowToolbar()) {
|
||||
else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) {
|
||||
topBar = <MatrixToolbar />;
|
||||
}
|
||||
else if (this.state.hasNewVersion) {
|
||||
|
|
Loading…
Reference in New Issue