mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -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.logout();
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.requestNotifications = function() {
|
|
||||||
if (window.Notification) {
|
|
||||||
console.log("Notification.permission: " + window.Notification.permission);
|
|
||||||
window.Notification.requestPermission(function(){});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
});
|
||||||
|
};
|
||||||
}]);
|
}]);
|
@ -53,6 +53,24 @@
|
|||||||
</div>
|
</div>
|
||||||
<br/>
|
<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>
|
<h3>Configuration</h3>
|
||||||
<div>
|
<div>
|
||||||
<div>Home server: {{ config.homeserver }} </div>
|
<div>Home server: {{ config.homeserver }} </div>
|
||||||
@ -61,11 +79,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<div>
|
|
||||||
<div><button ng-click="requestNotifications()">Request notifications</button></div>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
{{ feedback }}
|
{{ feedback }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user