mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 06:27:02 +03:00
Better Remote.saveAdminConfig() and better idleTrigger for them
This commit is contained in:
parent
2588e5b328
commit
3b40f86c33
11 changed files with 76 additions and 81 deletions
|
|
@ -1,32 +1,39 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { settingsSaveHelperSimpleFunction } from 'Common/Utils';
|
||||
import { settingsSaveHelperSimpleFunction, addObservablesTo, addSubscribablesTo } from 'Common/Utils';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
export class BrandingAdminSettings /*extends AbstractViewSettings*/ {
|
||||
constructor() {
|
||||
this.title = ko.observable(SettingsGet('Title')).idleTrigger();
|
||||
this.loadingDesc = ko.observable(SettingsGet('LoadingDescription')).idleTrigger();
|
||||
this.faviconUrl = ko.observable(SettingsGet('FaviconUrl')).idleTrigger();
|
||||
addObservablesTo(this, {
|
||||
title: SettingsGet('Title'),
|
||||
loadingDesc: SettingsGet('LoadingDescription'),
|
||||
faviconUrl: SettingsGet('FaviconUrl'),
|
||||
|
||||
this.title.subscribe(value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.title.trigger, this), {
|
||||
Title: value.trim()
|
||||
})
|
||||
);
|
||||
titleTrigger: SaveSettingsStep.Idle,
|
||||
loadingDescTrigger: SaveSettingsStep.Idle,
|
||||
faviconUrlTrigger: SaveSettingsStep.Idle
|
||||
});
|
||||
|
||||
this.loadingDesc.subscribe(value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.loadingDesc.trigger, this), {
|
||||
LoadingDescription: value.trim()
|
||||
})
|
||||
);
|
||||
addSubscribablesTo(this, {
|
||||
title: (value =>
|
||||
Remote.saveConfig({
|
||||
Title: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.titleTrigger, this))
|
||||
).debounce(999),
|
||||
|
||||
this.faviconUrl.subscribe(value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.faviconUrl.trigger, this), {
|
||||
FaviconUrl: value.trim()
|
||||
})
|
||||
);
|
||||
loadingDesc: (value =>
|
||||
Remote.saveConfig({
|
||||
LoadingDescription: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.loadingDescTrigger, this))
|
||||
).debounce(999),
|
||||
|
||||
faviconUrl: (value =>
|
||||
Remote.saveConfig({
|
||||
FaviconUrl: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.faviconUrlTrigger, this))
|
||||
).debounce(999)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue