mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 03:29:20 +03:00
Cleanup checkbox component
This commit is contained in:
parent
081761b593
commit
01d96153c6
6 changed files with 11 additions and 20 deletions
|
|
@ -8,20 +8,11 @@ class AbstractCheckbox extends AbstractComponent {
|
|||
constructor(params = {}) {
|
||||
super();
|
||||
|
||||
this.value = params.value;
|
||||
if (undefined === this.value || !this.value.subscribe) {
|
||||
this.value = ko.observable(!!this.value);
|
||||
}
|
||||
this.value = ko.isObservable(params.value) ? params.value
|
||||
: ko.observable(!!params.value);
|
||||
|
||||
this.enable = params.enable;
|
||||
if (undefined === this.enable || !this.enable.subscribe) {
|
||||
this.enable = ko.observable(undefined === this.enable || !!this.enable);
|
||||
}
|
||||
|
||||
this.disable = params.disable;
|
||||
if (undefined === this.disable || !this.disable.subscribe) {
|
||||
this.disable = ko.observable(!!this.disable);
|
||||
}
|
||||
this.enable = ko.isObservable(params.enable) ? params.enable
|
||||
: ko.observable(undefined === params.enable || !!params.enable);
|
||||
|
||||
this.label = params.label || '';
|
||||
this.inline = !!params.inline;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export class GeneralUserSettings {
|
|||
this.notificationSounds = ko.observableArray(SettingsGet('NewMailSounds'));
|
||||
|
||||
this.enableDesktopNotification = NotificationUserStore.enableDesktopNotification;
|
||||
this.isDesktopNotificationDenied = NotificationUserStore.isDesktopNotificationDenied;
|
||||
this.isDesktopNotificationAllowed = NotificationUserStore.isDesktopNotificationAllowed;
|
||||
|
||||
this.showImages = SettingsUserStore.showImages;
|
||||
this.removeColors = SettingsUserStore.removeColors;
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ export const NotificationUserStore = new class {
|
|||
|
||||
this.enableDesktopNotification = ko.observable(false)/*.extend({ notify: 'always' })*/;
|
||||
|
||||
this.isDesktopNotificationDenied = ko.observable(NotificationsDenied());
|
||||
this.isDesktopNotificationAllowed = ko.observable(!NotificationsDenied());
|
||||
|
||||
this.enableDesktopNotification.subscribe(value => {
|
||||
DesktopNotifications = !!value;
|
||||
if (value && HTML5Notification && !NotificationsGranted()) {
|
||||
HTML5Notification.requestPermission(() =>
|
||||
this.isDesktopNotificationDenied(NotificationsDenied())
|
||||
this.isDesktopNotificationAllowed(!NotificationsDenied())
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue