Underscore.js _.delay() to native setTimeout()

This commit is contained in:
djmaze 2020-07-22 20:28:25 +02:00
parent a82575a830
commit 43c92a82e6
29 changed files with 67 additions and 82 deletions

View file

@ -1,5 +1,4 @@
import ko from 'ko';
import _ from '_';
import { trim, triggerAutocompleteInputChange } from 'Common/Utils';
@ -103,7 +102,7 @@ class LoginAdminView extends AbstractViewNext {
onShow() {
routeOff();
_.delay(() => {
setTimeout(() => {
this.loginFocus(true);
}, Magics.Time100ms);
}

View file

@ -508,7 +508,7 @@ class ComposePopupView extends AbstractViewNext {
contactsCommand() {
if (this.allowContacts) {
this.skipCommand();
_.delay(() => {
setTimeout(() => {
showScreenPopup(require('View/Popup/Contacts'), [true, this.sLastFocusedField]);
}, Magics.Time200ms);
}
@ -706,7 +706,7 @@ class ComposePopupView extends AbstractViewNext {
editor(fOnInit) {
if (fOnInit) {
if (!this.oEditor && this.composeEditorArea()) {
// _.delay(() => {
// setTimeout(() => {
this.oEditor = new HtmlEditor(
this.composeEditorArea(),
null,
@ -1169,7 +1169,7 @@ class ComposePopupView extends AbstractViewNext {
setFocusInPopup() {
if (!bMobileDevice) {
_.delay(() => {
setTimeout(() => {
if ('' === this.to()) {
this.to.focused(true);
} else if (this.oEditor) {

View file

@ -178,7 +178,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
}
if (result && this.resultCallback) {
_.delay(() => {
setTimeout(() => {
let pgpPromise = null;
try {

View file

@ -276,7 +276,7 @@ class ContactsPopupView extends AbstractViewNext {
this.sLastComposeFocusedField = '';
_.delay(() => {
setTimeout(() => {
showScreenPopup(require('View/Popup/Compose'), [ComposeType.Empty, null, toEmails, ccEmails, bccEmails]);
}, Magics.Time200ms);
}
@ -327,14 +327,14 @@ class ContactsPopupView extends AbstractViewNext {
res = true;
}
_.delay(() => {
setTimeout(() => {
this.viewSaveTrigger(res ? SaveSettingsStep.TrueResult : SaveSettingsStep.FalseResult);
}, Magics.Time350ms);
if (res) {
this.watchDirty(false);
_.delay(() => {
setTimeout(() => {
this.viewSaveTrigger(SaveSettingsStep.Idle);
}, Magics.Time1s);
}
@ -470,7 +470,7 @@ class ContactsPopupView extends AbstractViewNext {
this.bDropPageAfterDelete = true;
}
_.delay(() => {
setTimeout(() => {
contacts.forEach(contact => {
koContacts.remove(contact);
delegateRunOnDestroy(contact);
@ -495,7 +495,7 @@ class ContactsPopupView extends AbstractViewNext {
if (Magics.Time500ms < (StorageResultType.Success === sResult && oData && oData.Time ? pInt(oData.Time) : 0)) {
this.reloadContactList(this.bDropPageAfterDelete);
} else {
_.delay(() => {
setTimeout(() => {
this.reloadContactList(this.bDropPageAfterDelete);
}, Magics.Time500ms);
}

View file

@ -1,4 +1,3 @@
import _ from '_';
import ko from 'ko';
import key from 'key';
import $ from '$';
@ -37,7 +36,7 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
doCommand() {
this.submitRequest(true);
_.delay(() => {
setTimeout(() => {
let privateKey = null;
try {

View file

@ -1,4 +1,3 @@
import _ from '_';
import ko from 'ko';
import { Magics } from 'Common/Enums';
@ -53,7 +52,7 @@ class NewOpenPgpKeyPopupView extends AbstractViewNext {
this.submitRequest(true);
this.submitError('');
_.delay(() => {
setTimeout(() => {
try {
PgpStore.openpgp
.generateKey({

View file

@ -1,4 +1,3 @@
import _ from '_';
import ko from 'ko';
import key from 'key';
@ -54,7 +53,7 @@ class AbstractSystemDropDownUserView extends AbstractViewNext {
accountClick(account, event) {
if (account && event && !isUnd(event.which) && 1 === event.which) {
AccountStore.accounts.loading(true);
_.delay(() => AccountStore.accounts.loading(false), Magics.Time1s);
setTimeout(() => AccountStore.accounts.loading(false), Magics.Time1s);
}
return true;

View file

@ -1,4 +1,3 @@
import _ from '_';
import ko from 'ko';
import {
@ -217,7 +216,7 @@ class LoginUserView extends AbstractViewNext {
this.additionalCode.visibility(true);
this.submitRequest(false);
_.delay(() => this.additionalCode.focused(true), Magics.Time100ms);
setTimeout(() => this.additionalCode.focused(true), Magics.Time100ms);
} else if (oData.Admin) {
getApp().redirectToAdminPanel();
} else {
@ -317,7 +316,7 @@ class LoginUserView extends AbstractViewNext {
this.email(AppStore.devEmail);
this.password(AppStore.devPassword);
_.delay(() => {
setTimeout(() => {
LanguageStore.language.subscribe((value) => {
this.langRequest(true);
@ -346,7 +345,7 @@ class LoginUserView extends AbstractViewNext {
selectLanguageOnTab(bShift) {
if (!bShift) {
_.delay(() => {
setTimeout(() => {
this.emailFocus(true);
}, Magics.Time50ms);

View file

@ -262,7 +262,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
if (message) {
this.showAttachmnetControls(false);
if (Local.get(ClientSideKeyName.MessageAttachmnetControls)) {
_.delay(() => {
setTimeout(() => {
this.showAttachmnetControls(true);
}, Magics.Time50ms);
}
@ -547,9 +547,9 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
Events.sub(
'window.resize',
_.throttle(() => {
_.delay(fCheckHeaderHeight, 1);
_.delay(fCheckHeaderHeight, Magics.Time200ms);
_.delay(fCheckHeaderHeight, Magics.Time500ms);
setTimeout(fCheckHeaderHeight, 1);
setTimeout(fCheckHeaderHeight, Magics.Time200ms);
setTimeout(fCheckHeaderHeight, Magics.Time500ms);
}, Magics.Time50ms)
);