Replace deprecated Knockout throttle with new debounce extender

Replace admin general mainAttachmentLimit with input type="number"
This commit is contained in:
djmaze 2021-02-10 12:12:36 +01:00
parent 75b7176ada
commit 8c780ad353
18 changed files with 45 additions and 84 deletions

View file

@ -9,7 +9,7 @@ class AccountUserStore {
});
this.accounts = ko.observableArray();
this.accounts.loading = ko.observable(false).extend({ throttle: 100 });
this.accounts.loading = ko.observable(false).extend({ debounce: 100 });
this.getEmailAddresses = () => this.accounts.map(item => item ? item.email : null).filter(v => v);

View file

@ -3,11 +3,11 @@ import ko from 'ko';
class ContactUserStore {
constructor() {
this.contacts = ko.observableArray();
this.contacts.loading = ko.observable(false).extend({ throttle: 200 });
this.contacts.importing = ko.observable(false).extend({ throttle: 200 });
this.contacts.syncing = ko.observable(false).extend({ throttle: 200 });
this.contacts.exportingVcf = ko.observable(false).extend({ throttle: 200 });
this.contacts.exportingCsv = ko.observable(false).extend({ throttle: 200 });
this.contacts.loading = ko.observable(false).extend({ debounce: 200 });
this.contacts.importing = ko.observable(false).extend({ debounce: 200 });
this.contacts.syncing = ko.observable(false).extend({ debounce: 200 });
this.contacts.exportingVcf = ko.observable(false).extend({ debounce: 200 });
this.contacts.exportingCsv = ko.observable(false).extend({ debounce: 200 });
ko.addObservablesTo(this, {
allowContactsSync: false,

View file

@ -3,7 +3,7 @@ import ko from 'ko';
class IdentityUserStore {
constructor() {
this.identities = ko.observableArray();
this.identities.loading = ko.observable(false).extend({ throttle: 100 });
this.identities.loading = ko.observable(false).extend({ debounce: 100 });
this.getIDS = () => this.identities.map(item => (item ? item.id() : null)).filter(value => null !== value);
}

View file

@ -57,7 +57,7 @@ class MessageUserStore {
constructor() {
this.staticMessage = new MessageModel();
this.messageList = ko.observableArray().extend({ rateLimit: 0 });
this.messageList = ko.observableArray().extend({ debounce: 0 });
ko.addObservablesTo(this, {
messageListCount: 0,
@ -93,12 +93,12 @@ class MessageUserStore {
messageActiveDom: null
});
this.messageListCompleteLoadingThrottle = ko.observable(false).extend({ throttle: 200 });
this.messageListCompleteLoadingThrottleForAnimation = ko.observable(false).extend({ specialThrottle: 700 });
this.messageListCompleteLoadingThrottle = ko.observable(false).extend({ debounce: 200 });
this.messageListCompleteLoadingThrottleForAnimation = ko.observable(false);
this.messageListDisableAutoSelect = ko.observable(false).extend({ falseTimeout: 500 });
this.messageLoadingThrottle = ko.observable(false).extend({ throttle: 50 });
this.messageLoadingThrottle = ko.observable(false).extend({ debounce: 50 });
this.messageLoading = ko.computed(() => this.messageCurrentLoading());
@ -184,10 +184,22 @@ class MessageUserStore {
}
subscribers() {
let timer = 0, fn = this.messageListCompleteLoadingThrottleForAnimation;
this.messageListCompleteLoading.subscribe((value) => {
value = !!value;
this.messageListCompleteLoadingThrottle(value);
this.messageListCompleteLoadingThrottleForAnimation(value);
if (value) {
fn(value);
} else if (fn()) {
clearTimeout(timer);
timer = setTimeout(() => {
fn(value);
timer = 0;
}, 700);
} else {
fn(value);
}
});
this.messageList.subscribe(

View file

@ -5,9 +5,9 @@ import ko from 'ko';
class TemplateUserStore {
constructor() {
this.templates = ko.observableArray();
this.templates.loading = ko.observable(false).extend({ throttle: 100 });
this.templates.loading = ko.observable(false).extend({ debounce: 100 });
this.templatesNames = ko.observableArray().extend({ throttle: 1000 });
this.templatesNames = ko.observableArray().extend({ debounce: 1000 });
this.templatesNames.skipFirst = true;
this.subscribers();