prettier --write

This commit is contained in:
RainLoop Team 2019-07-04 22:19:24 +03:00
parent 450528ff00
commit 8a0be3212d
164 changed files with 7053 additions and 9008 deletions

View file

@ -1,110 +1,87 @@
import window from 'window';
import ko from 'ko';
import {DesktopNotification, Magics} from 'Common/Enums';
import { DesktopNotification, Magics } from 'Common/Enums';
import * as Events from 'Common/Events';
import Audio from 'Common/Audio';
import * as Settings from 'Storage/Settings';
class NotificationUserStore
{
class NotificationUserStore {
constructor() {
this.enableSoundNotification = ko.observable(false);
this.soundNotificationIsSupported = ko.observable(false);
this.allowDesktopNotification = ko.observable(false);
this.desktopNotificationPermissions = ko.computed(() => {
this.desktopNotificationPermissions = ko
.computed(() => {
this.allowDesktopNotification();
this.allowDesktopNotification();
let result = DesktopNotification.NotSupported;
let result = DesktopNotification.NotSupported;
const NotificationClass = this.notificationClass();
if (NotificationClass && NotificationClass.permission)
{
switch (NotificationClass.permission.toLowerCase())
{
case 'granted':
result = DesktopNotification.Allowed;
break;
case 'denied':
result = DesktopNotification.Denied;
break;
case 'default':
result = DesktopNotification.NotAllowed;
break;
// no default
const NotificationClass = this.notificationClass();
if (NotificationClass && NotificationClass.permission) {
switch (NotificationClass.permission.toLowerCase()) {
case 'granted':
result = DesktopNotification.Allowed;
break;
case 'denied':
result = DesktopNotification.Denied;
break;
case 'default':
result = DesktopNotification.NotAllowed;
break;
// no default
}
} else if (window.webkitNotifications && window.webkitNotifications.checkPermission) {
result = window.webkitNotifications.checkPermission();
}
}
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
{
result = window.webkitNotifications.checkPermission();
}
return result;
return result;
})
.extend({ notify: 'always' });
}).extend({notify: 'always'});
this.enableDesktopNotification = ko
.computed({
read: () =>
this.allowDesktopNotification() && DesktopNotification.Allowed === this.desktopNotificationPermissions(),
write: (value) => {
if (value) {
const NotificationClass = this.notificationClass(),
permission = this.desktopNotificationPermissions();
this.enableDesktopNotification = ko.computed({
read: () => this.allowDesktopNotification() && DesktopNotification.Allowed === this.desktopNotificationPermissions(),
write: (value) => {
if (value)
{
const
NotificationClass = this.notificationClass(),
permission = this.desktopNotificationPermissions();
if (NotificationClass && DesktopNotification.Allowed === permission) {
this.allowDesktopNotification(true);
} else if (NotificationClass && DesktopNotification.NotAllowed === permission) {
NotificationClass.requestPermission(() => {
this.allowDesktopNotification.valueHasMutated();
if (NotificationClass && DesktopNotification.Allowed === permission)
{
this.allowDesktopNotification(true);
}
else if (NotificationClass && DesktopNotification.NotAllowed === permission)
{
NotificationClass.requestPermission(() => {
this.allowDesktopNotification.valueHasMutated();
if (DesktopNotification.Allowed === this.desktopNotificationPermissions())
{
if (this.allowDesktopNotification())
{
this.allowDesktopNotification.valueHasMutated();
if (DesktopNotification.Allowed === this.desktopNotificationPermissions()) {
if (this.allowDesktopNotification()) {
this.allowDesktopNotification.valueHasMutated();
} else {
this.allowDesktopNotification(true);
}
} else {
if (this.allowDesktopNotification()) {
this.allowDesktopNotification(false);
} else {
this.allowDesktopNotification.valueHasMutated();
}
}
else
{
this.allowDesktopNotification(true);
}
}
else
{
if (this.allowDesktopNotification())
{
this.allowDesktopNotification(false);
}
else
{
this.allowDesktopNotification.valueHasMutated();
}
}
});
}
else
{
});
} else {
this.allowDesktopNotification(false);
}
} else {
this.allowDesktopNotification(false);
}
}
else
{
this.allowDesktopNotification(false);
}
}
}).extend({notify: 'always'});
})
.extend({ notify: 'always' });
if (!this.enableDesktopNotification.valueHasMutated)
{
if (!this.enableDesktopNotification.valueHasMutated) {
this.enableDesktopNotification.valueHasMutated = () => {
this.allowDesktopNotification.valueHasMutated();
};
@ -121,72 +98,64 @@ class NotificationUserStore
);
this.isDesktopNotificationDenied = ko.computed(
() => DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
() =>
DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
DesktopNotification.Denied === this.desktopNotificationPermissions()
);
}
initNotificationPlayer() {
if (Audio && Audio.supportedNotification)
{
if (Audio && Audio.supportedNotification) {
this.soundNotificationIsSupported(true);
}
else
{
} else {
this.enableSoundNotification(false);
this.soundNotificationIsSupported(false);
}
}
playSoundNotification(skipSetting) {
if (Audio && Audio.supportedNotification && (skipSetting ? true : this.enableSoundNotification()))
{
if (Audio && Audio.supportedNotification && (skipSetting ? true : this.enableSoundNotification())) {
Audio.playNotification();
}
}
displayDesktopNotification(imageSrc, title, text, nessageData) {
if (this.enableDesktopNotification())
{
const
NotificationClass = this.notificationClass(),
notification = NotificationClass ? new NotificationClass(title, {
body: text,
icon: imageSrc
}) : null;
if (this.enableDesktopNotification()) {
const NotificationClass = this.notificationClass(),
notification = NotificationClass
? new NotificationClass(title, {
body: text,
icon: imageSrc
})
: null;
if (notification)
{
if (notification.show)
{
if (notification) {
if (notification.show) {
notification.show();
}
if (nessageData)
{
if (nessageData) {
notification.onclick = () => {
window.focus();
if (nessageData.Folder && nessageData.Uid)
{
if (nessageData.Folder && nessageData.Uid) {
Events.pub('mailbox.message.show', [nessageData.Folder, nessageData.Uid]);
}
};
}
window.setTimeout((function(localNotifications) {
return () => {
if (localNotifications.cancel)
{
localNotifications.cancel();
}
else if (localNotifications.close)
{
localNotifications.close();
}
};
}(notification)), Magics.Time7s);
window.setTimeout(
(function(localNotifications) {
return () => {
if (localNotifications.cancel) {
localNotifications.cancel();
} else if (localNotifications.close) {
localNotifications.close();
}
};
})(notification),
Magics.Time7s
);
}
}
}