mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
More changes for https://github.com/the-djmaze/snappymail/issues/37
Notifications were hardcoded disabled for mobile.
This commit is contained in:
parent
542d9c91e9
commit
f706e14a2f
2 changed files with 10 additions and 8 deletions
|
|
@ -8,6 +8,8 @@ import * as Links from 'Common/Links';
|
||||||
*/
|
*/
|
||||||
const HTML5Notification = window.Notification ? Notification : null,
|
const HTML5Notification = window.Notification ? Notification : null,
|
||||||
HTML5NotificationStatus = () => (HTML5Notification && HTML5Notification.permission) || 'denied',
|
HTML5NotificationStatus = () => (HTML5Notification && HTML5Notification.permission) || 'denied',
|
||||||
|
NotificationsDenied = () => 'denied' === HTML5NotificationStatus(),
|
||||||
|
NotificationsGranted = () => 'granted' === HTML5NotificationStatus(),
|
||||||
dispatchMessage = data => {
|
dispatchMessage = data => {
|
||||||
focus();
|
focus();
|
||||||
if (data.Folder && data.Uid) {
|
if (data.Folder && data.Uid) {
|
||||||
|
|
@ -20,7 +22,6 @@ let DesktopNotifications = false,
|
||||||
|
|
||||||
// Are Notifications supported in the service worker?
|
// Are Notifications supported in the service worker?
|
||||||
if (WorkerNotifications && ServiceWorkerRegistration && ServiceWorkerRegistration.prototype.showNotification) {
|
if (WorkerNotifications && ServiceWorkerRegistration && ServiceWorkerRegistration.prototype.showNotification) {
|
||||||
console.log('ServiceWorker supported');
|
|
||||||
/* Listen for close requests from the ServiceWorker */
|
/* Listen for close requests from the ServiceWorker */
|
||||||
WorkerNotifications.addEventListener('message', event => {
|
WorkerNotifications.addEventListener('message', event => {
|
||||||
const obj = JSON.parse(event.data);
|
const obj = JSON.parse(event.data);
|
||||||
|
|
@ -28,7 +29,7 @@ if (WorkerNotifications && ServiceWorkerRegistration && ServiceWorkerRegistratio
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
WorkerNotifications = null;
|
WorkerNotifications = null;
|
||||||
console.log('WorkerNotifications not supported');
|
console.log('ServiceWorker Notifications not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
class NotificationUserStore {
|
class NotificationUserStore {
|
||||||
|
|
@ -37,13 +38,13 @@ class NotificationUserStore {
|
||||||
|
|
||||||
this.enableDesktopNotification = ko.observable(false)/*.extend({ notify: 'always' })*/;
|
this.enableDesktopNotification = ko.observable(false)/*.extend({ notify: 'always' })*/;
|
||||||
|
|
||||||
this.isDesktopNotificationDenied = ko.observable('denied' === HTML5NotificationStatus());
|
this.isDesktopNotificationDenied = ko.observable(NotificationsDenied());
|
||||||
|
|
||||||
this.enableDesktopNotification.subscribe(value => {
|
this.enableDesktopNotification.subscribe(value => {
|
||||||
DesktopNotifications = !!value;
|
DesktopNotifications = !!value;
|
||||||
if (value && HTML5Notification && 'granted' !== HTML5Notification.permission) {
|
if (value && HTML5Notification && !NotificationsGranted()) {
|
||||||
HTML5Notification.requestPermission(() =>
|
HTML5Notification.requestPermission(() =>
|
||||||
this.isDesktopNotificationDenied('denied' === HTML5Notification.permission)
|
this.isDesktopNotificationDenied(NotificationsDenied())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -62,12 +63,15 @@ class NotificationUserStore {
|
||||||
* Used with DesktopNotifications setting
|
* Used with DesktopNotifications setting
|
||||||
*/
|
*/
|
||||||
displayDesktopNotification(title, text, messageData, imageSrc) {
|
displayDesktopNotification(title, text, messageData, imageSrc) {
|
||||||
if (DesktopNotifications && 'granted' === HTML5NotificationStatus()) {
|
if (DesktopNotifications && NotificationsGranted()) {
|
||||||
const options = {
|
const options = {
|
||||||
body: text,
|
body: text,
|
||||||
icon: imageSrc || Links.notificationMailIcon(),
|
icon: imageSrc || Links.notificationMailIcon(),
|
||||||
data: messageData
|
data: messageData
|
||||||
};
|
};
|
||||||
|
if (messageData && messageData.Uid) {
|
||||||
|
options.tag = messageData.Uid;
|
||||||
|
}
|
||||||
if (WorkerNotifications) {
|
if (WorkerNotifications) {
|
||||||
// Service-Worker-Allowed HTTP header to allow the scope.
|
// Service-Worker-Allowed HTTP header to allow the scope.
|
||||||
WorkerNotifications.register('/serviceworker.js')
|
WorkerNotifications.register('/serviceworker.js')
|
||||||
|
|
|
||||||
|
|
@ -1480,8 +1480,6 @@ NewThemeLink IncludeCss TemplatesLink LangLink IncludeBackground PluginsLink Aut
|
||||||
{
|
{
|
||||||
$aResult['Layout'] = Enumerations\Layout::NO_PREVIW;
|
$aResult['Layout'] = Enumerations\Layout::NO_PREVIW;
|
||||||
|
|
||||||
$aResult['SoundNotification'] = false;
|
|
||||||
$aResult['DesktopNotifications'] = false;
|
|
||||||
$aResult['UseCheckboxesInList'] = true;
|
$aResult['UseCheckboxesInList'] = true;
|
||||||
|
|
||||||
$aResult['UserBackgroundName'] = '';
|
$aResult['UserBackgroundName'] = '';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue