You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
unwanted functions removed, prev functions modified
This commit is contained in:
@ -123,28 +123,6 @@ var Notifier = {
|
|||||||
return global.Notification.permission == 'granted';
|
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) {
|
setEnabled: function(enable, callback) {
|
||||||
// make sure that we persist the current setting audio_enabled setting
|
// make sure that we persist the current setting audio_enabled setting
|
||||||
// before changing anything
|
// before changing anything
|
||||||
@ -156,33 +134,22 @@ var Notifier = {
|
|||||||
|
|
||||||
if(enable) {
|
if(enable) {
|
||||||
// Case when we do not have the permission as 'granted'
|
// Case when we do not have the permission as 'granted'
|
||||||
if (this.isPermissionDefault()) {
|
// Attempt to get permission from user
|
||||||
// Attempt to get permission from user
|
global.Notification.requestPermission(function(result) {
|
||||||
var self = this;
|
if (result !== 'granted') {
|
||||||
global.Notification.requestPermission(function(result) {
|
// The permission request was dismissed or denied
|
||||||
if (result === 'denied') {
|
return;
|
||||||
dis.dispatch({
|
}
|
||||||
action: "notifier_enabled",
|
|
||||||
value: false
|
|
||||||
});
|
|
||||||
self.setToolbarHidden(true, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (result === 'default') {
|
|
||||||
// The permission request was dismissed
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "notifier_enabled",
|
action: "notifier_enabled",
|
||||||
value: true
|
value: true
|
||||||
});
|
|
||||||
|
|
||||||
if (!global.localStorage) return;
|
|
||||||
global.localStorage.setItem('notifications_enabled', 'true');
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
if (!global.localStorage) return;
|
||||||
|
global.localStorage.setItem('notifications_enabled', 'true');
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!global.localStorage) return;
|
if (!global.localStorage) return;
|
||||||
global.localStorage.setItem('notifications_enabled', 'false');
|
global.localStorage.setItem('notifications_enabled', 'false');
|
||||||
@ -232,6 +199,13 @@ var Notifier = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
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;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1046,7 +1046,7 @@ module.exports = React.createClass({
|
|||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
topBar = <GuestWarningBar />;
|
topBar = <GuestWarningBar />;
|
||||||
}
|
}
|
||||||
else if (Notifier.supportsDesktopNotifications() && Notifier.shouldShowToolbar()) {
|
else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) {
|
||||||
topBar = <MatrixToolbar />;
|
topBar = <MatrixToolbar />;
|
||||||
}
|
}
|
||||||
else if (this.state.hasNewVersion) {
|
else if (this.state.hasNewVersion) {
|
||||||
|
Reference in New Issue
Block a user