change AbstractFetchRemote with a better structure

This commit is contained in:
djmaze 2021-12-02 23:15:24 +01:00
parent 0d809dd574
commit 792fee547a
26 changed files with 265 additions and 723 deletions

View file

@ -43,8 +43,7 @@ class AccountPopupView extends AbstractViewPopup {
this.submitRequest(true);
Remote.accountSetup(
(iError, data) => {
Remote.request('AccountSetup', (iError, data) => {
this.submitRequest(false);
if (iError) {
this.submitError(getNotification(iError));
@ -53,10 +52,11 @@ class AccountPopupView extends AbstractViewPopup {
rl.app.accountsAndIdentities();
this.cancelCommand();
}
},
this.email(),
this.password(),
this.isNew()
}, {
Email: this.email(),
Password: this.password(),
New: this.isNew() ? 1 : 0
}
);
return true;

View file

@ -415,7 +415,7 @@ class ComposePopupView extends AbstractViewPopup {
setFolderHash(this.draftsFolder(), '');
setFolderHash(sSentFolder, '');
Remote.sendMessage(
Remote.request('SendMessage',
(iError, data) => {
this.sending(false);
if (this.modalVisibility()) {
@ -434,7 +434,8 @@ class ComposePopupView extends AbstractViewPopup {
}
this.reloadDraftFolder();
},
this.getMessageRequestParams(sSentFolder)
this.getMessageRequestParams(sSentFolder),
30000
);
}
}
@ -451,7 +452,7 @@ class ComposePopupView extends AbstractViewPopup {
setFolderHash(FolderUserStore.draftsFolder(), '');
Remote.saveMessage(
Remote.request('SaveMessage',
(iError, oData) => {
let result = false;
@ -486,7 +487,8 @@ class ComposePopupView extends AbstractViewPopup {
this.reloadDraftFolder();
},
this.getMessageRequestParams(FolderUserStore.draftsFolder())
this.getMessageRequestParams(FolderUserStore.draftsFolder()),
200000
);
}
@ -1016,30 +1018,36 @@ class ComposePopupView extends AbstractViewPopup {
const downloads = this.getAttachmentsDownloadsForUpload();
if (arrayLength(downloads)) {
Remote.messageUploadAttachments((iError, oData) => {
if (!iError) {
forEachObjectEntry(oData.Result, (tempName, id) => {
const attachment = this.getAttachmentById(id);
if (attachment) {
attachment.tempName(tempName);
attachment
.waiting(false)
.uploading(false)
.complete(true);
}
});
} else {
this.attachments.forEach(attachment => {
if (attachment && attachment.fromMessage) {
attachment
.waiting(false)
.uploading(false)
.complete(true)
.error(getUploadErrorDescByCode(UploadErrorCode.NoFileUploaded));
}
});
}
}, downloads);
Remote.request('MessageUploadAttachments',
(iError, oData) => {
if (!iError) {
forEachObjectEntry(oData.Result, (tempName, id) => {
const attachment = this.getAttachmentById(id);
if (attachment) {
attachment.tempName(tempName);
attachment
.waiting(false)
.uploading(false)
.complete(true);
}
});
} else {
this.attachments.forEach(attachment => {
if (attachment && attachment.fromMessage) {
attachment
.waiting(false)
.uploading(false)
.complete(true)
.error(getUploadErrorDescByCode(UploadErrorCode.NoFileUploaded));
}
});
}
},
{
Attachments: downloads
},
999000
);
}
if (identity) {

View file

@ -217,7 +217,7 @@ class ContactsPopupView extends AbstractViewPopup {
const requestUid = Jua.randomId();
Remote.contactSave(
Remote.request('ContactSave',
(iError, oData) => {
let res = false;
this.viewSaving(false);
@ -243,10 +243,11 @@ class ContactsPopupView extends AbstractViewPopup {
this.watchDirty(false);
setTimeout(() => this.viewSaveTrigger(SaveSettingsStep.Idle), 1000);
}
},
requestUid,
this.viewID(),
this.viewProperties.map(oItem => oItem.toJSON())
}, {
RequestUid: requestUid,
Uid: this.viewID(),
Properties: this.viewProperties.map(oItem => oItem.toJSON())
}
);
}
@ -355,14 +356,17 @@ class ContactsPopupView extends AbstractViewPopup {
deleteSelectedContacts() {
if (this.contactsCheckedOrSelected().length) {
Remote.contactsDelete((iError, oData) => {
if (500 < (!iError && oData && oData.Time ? pInt(oData.Time) : 0)) {
this.reloadContactList(this.bDropPageAfterDelete);
} else {
setTimeout(() => this.reloadContactList(this.bDropPageAfterDelete), 500);
Remote.request('ContactsDelete',
(iError, oData) => {
if (500 < (!iError && oData && oData.Time ? pInt(oData.Time) : 0)) {
this.reloadContactList(this.bDropPageAfterDelete);
} else {
setTimeout(() => this.reloadContactList(this.bDropPageAfterDelete), 500);
}
}, {
Uids: this.contactsCheckedOrSelectedUids().join(',')
}
}, this.contactsCheckedOrSelectedUids());
);
this.removeCheckedOrSelectedContactsFromList();
}
}
@ -415,7 +419,7 @@ class ContactsPopupView extends AbstractViewPopup {
}
ContactUserStore.loading(true);
Remote.contacts(
Remote.request('Contacts',
(iError, data) => {
let count = 0,
list = [];
@ -438,9 +442,14 @@ class ContactsPopupView extends AbstractViewPopup {
ContactUserStore.loading(false);
this.viewClearSearch(!!this.search());
},
offset,
CONTACTS_PER_PAGE,
this.search()
{
Offset: offset,
Limit: CONTACTS_PER_PAGE,
Search: this.search()
},
null,
'',
['Contacts']
);
}

View file

@ -54,7 +54,7 @@ class FolderClearPopupView extends AbstractViewPopup {
setFolderHash(folderToClear.fullName, '');
Remote.folderClear(iError => {
Remote.request('FolderClear', iError => {
this.clearingProcess(false);
if (iError) {
this.clearingError(getNotification(iError));
@ -62,7 +62,9 @@ class FolderClearPopupView extends AbstractViewPopup {
rl.app.reloadMessageList(true);
this.cancelCommand();
}
}, folderToClear.fullName);
}, {
Folder: folderToClear.fullName
});
}
}

View file

@ -50,7 +50,10 @@ class FolderCreatePopupView extends AbstractViewPopup {
}
rl.app.foldersPromisesActionHelper(
Remote.folderCreate(this.folderName(), parentFolderName),
Remote.post('FolderCreate', FolderUserStore.foldersCreating, {
Folder: this.folderName(),
Parent: parentFolderName
}),
Notification.CantCreateFolder
);

View file

@ -94,8 +94,7 @@ class IdentityPopupView extends AbstractViewPopup {
this.submitRequest(true);
Remote.identityUpdate(
iError => {
Remote.request('IdentityUpdate', iError => {
this.submitRequest(false);
if (iError) {
this.submitError(getNotification(iError));
@ -103,14 +102,15 @@ class IdentityPopupView extends AbstractViewPopup {
rl.app.accountsAndIdentities();
this.cancelCommand();
}
},
this.id,
this.email(),
this.name(),
this.replyTo(),
this.bcc(),
this.signature(),
this.signatureInsertBefore()
}, {
Id: this.id,
Email: this.email(),
Name: this.name(),
ReplyTo: this.replyTo(),
Bcc: this.bcc(),
Signature: this.signature(),
SignatureInsertBefore: this.signatureInsertBefore() ? 1 : 0
}
);
return true;

View file

@ -57,7 +57,7 @@ class SieveScriptPopupView extends AbstractViewPopup {
script.body(script.filtersToRaw());
}
Remote.filtersScriptSave(
Remote.request('FiltersScriptSave',
(iError, data) => {
self.saving = false;
@ -70,7 +70,7 @@ class SieveScriptPopupView extends AbstractViewPopup {
script.hasChanges(false);
}
},
script
script.toJson()
);
}