mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Show desktop notification state. Provide help if the user has previously denied permission to display them.
This commit is contained in:
parent
0ef54caa28
commit
c3a774e414
@ -69,13 +69,6 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
|
||||
$scope.logout();
|
||||
});
|
||||
|
||||
$scope.requestNotifications = function() {
|
||||
if (window.Notification) {
|
||||
console.log("Notification.permission: " + window.Notification.permission);
|
||||
window.Notification.requestPermission(function(){});
|
||||
}
|
||||
};
|
||||
|
||||
}]);
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu
|
||||
displayName: $scope.config.displayName,
|
||||
avatarUrl: $scope.config.avatarUrl
|
||||
};
|
||||
|
||||
|
||||
$scope.$watch("profile.avatarFile", function(newValue, oldValue) {
|
||||
if ($scope.profile.avatarFile) {
|
||||
console.log("Uploading new avatar file...");
|
||||
@ -143,4 +143,23 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/*** Desktop notifications section ***/
|
||||
$scope.settings = {
|
||||
notifications: undefined
|
||||
};
|
||||
|
||||
// If the browser supports it, check the desktop notification state
|
||||
if ("Notification" in window) {
|
||||
$scope.settings.notifications = window.Notification.permission;
|
||||
}
|
||||
|
||||
$scope.requestNotifications = function() {
|
||||
console.log("requestNotifications");
|
||||
window.Notification.requestPermission(function (permission) {
|
||||
console.log(" -> User decision: " + permission);
|
||||
$scope.settings.notifications = permission;
|
||||
});
|
||||
};
|
||||
}]);
|
@ -52,7 +52,25 @@
|
||||
</table>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
|
||||
<h3>Desktop notifications</h3>
|
||||
<div ng-switch="settings.notifications">
|
||||
<div ng-switch-when="granted">
|
||||
Notifications are enabled.
|
||||
</div>
|
||||
<div ng-switch-when="denied">
|
||||
You have denied permission for notifications.<br/>
|
||||
To enable it, reset the notification setting for this web site into your browser settings.
|
||||
</div>
|
||||
<div ng-switch-when="default">
|
||||
<button ng-click="requestNotifications()">Click here to enable them</button>
|
||||
</div>
|
||||
<div ng-switch-default="">
|
||||
Sorry, your browser does not support notifications.
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<h3>Configuration</h3>
|
||||
<div>
|
||||
<div>Home server: {{ config.homeserver }} </div>
|
||||
@ -60,11 +78,6 @@
|
||||
<div>Access token: {{ config.access_token }} </div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div>
|
||||
<div><button ng-click="requestNotifications()">Request notifications</button></div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
{{ feedback }}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user