mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 15:45:55 +08:00
Cleanup .bind(
This commit is contained in:
parent
9ec84baa32
commit
29fe73d4e7
|
@ -11,31 +11,18 @@ export class CheckboxMaterialDesignComponent extends AbstractCheckbox {
|
|||
this.animationBox = ko.observable(false).extend({ falseTimeout: 200 });
|
||||
this.animationCheckmark = ko.observable(false).extend({ falseTimeout: 200 });
|
||||
|
||||
this.animationBoxSetTrue = this.animationBoxSetTrue.bind(this);
|
||||
this.animationCheckmarkSetTrue = this.animationCheckmarkSetTrue.bind(this);
|
||||
|
||||
this.disposable.push(
|
||||
this.value.subscribe((value) => {
|
||||
this.triggerAnimation(value);
|
||||
}, this)
|
||||
this.value.subscribe(value => this.triggerAnimation(value), this)
|
||||
);
|
||||
}
|
||||
|
||||
animationBoxSetTrue() {
|
||||
this.animationBox(true);
|
||||
}
|
||||
|
||||
animationCheckmarkSetTrue() {
|
||||
this.animationCheckmark(true);
|
||||
}
|
||||
|
||||
triggerAnimation(box) {
|
||||
if (box) {
|
||||
this.animationBoxSetTrue();
|
||||
setTimeout(this.animationCheckmarkSetTrue, 200);
|
||||
this.animationBox(true);
|
||||
setTimeout(()=>this.animationCheckmark(true), 200);
|
||||
} else {
|
||||
this.animationCheckmarkSetTrue();
|
||||
setTimeout(this.animationBoxSetTrue, 200);
|
||||
this.animationCheckmark(true);
|
||||
setTimeout(()=>this.animationBox(true), 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,8 +220,6 @@ export const MessageUserStore = new class {
|
|||
}
|
||||
});
|
||||
|
||||
this.onMessageResponse = this.onMessageResponse.bind(this);
|
||||
|
||||
this.purgeMessageBodyCacheThrottle = this.purgeMessageBodyCache.throttle(30000);
|
||||
}
|
||||
|
||||
|
@ -630,16 +628,7 @@ export const MessageUserStore = new class {
|
|||
if (oMessage) {
|
||||
this.hideMessageBodies();
|
||||
this.messageLoading(true);
|
||||
Remote.message(this.onMessageResponse, oMessage.folder, oMessage.uid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sResult
|
||||
* @param {FetchJsonDefaultResponse} oData
|
||||
* @param {boolean} bCached
|
||||
*/
|
||||
onMessageResponse(iError, oData, bCached) {
|
||||
Remote.message((iError, oData, bCached) => {
|
||||
if (iError) {
|
||||
if (Notification.RequestAborted !== iError) {
|
||||
this.message(null);
|
||||
|
@ -649,6 +638,8 @@ export const MessageUserStore = new class {
|
|||
this.setMessage(oData, bCached);
|
||||
}
|
||||
this.messageLoading(false);
|
||||
}, oMessage.folder, oMessage.uid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -419,7 +419,24 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
setFolderHash(sSentFolder, '');
|
||||
|
||||
Remote.sendMessage(
|
||||
this.sendMessageResponse.bind(this),
|
||||
(iError, data) => {
|
||||
this.sending(false);
|
||||
if (this.modalVisibility()) {
|
||||
if (iError) {
|
||||
if (Notification.CantSaveMessage === iError) {
|
||||
this.sendSuccessButSaveError(true);
|
||||
this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
|
||||
} else {
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage)
|
||||
|| getNotification(Notification.CantSendMessage));
|
||||
}
|
||||
} else {
|
||||
this.closeCommand && this.closeCommand();
|
||||
}
|
||||
}
|
||||
this.reloadDraftFolder();
|
||||
},
|
||||
this.getMessageRequestParams(sSentFolder)
|
||||
);
|
||||
}
|
||||
|
@ -438,7 +455,40 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
setFolderHash(FolderUserStore.draftFolder(), '');
|
||||
|
||||
Remote.saveMessage(
|
||||
this.saveMessageResponse.bind(this),
|
||||
(iError, oData) => {
|
||||
let result = false;
|
||||
|
||||
this.saving(false);
|
||||
|
||||
if (!iError) {
|
||||
if (oData.Result.NewFolder && oData.Result.NewUid) {
|
||||
result = true;
|
||||
|
||||
if (this.bFromDraft) {
|
||||
const message = MessageUserStore.message();
|
||||
if (message && this.draftFolder() === message.folder && this.draftUid() === message.uid) {
|
||||
MessageUserStore.message(null);
|
||||
}
|
||||
}
|
||||
|
||||
this.draftFolder(oData.Result.NewFolder);
|
||||
this.draftUid(oData.Result.NewUid);
|
||||
|
||||
this.savedTime(new Date);
|
||||
|
||||
if (this.bFromDraft) {
|
||||
setFolderHash(this.draftFolder(), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
this.savedError(true);
|
||||
this.savedErrorDesc(getNotification(Notification.CantSaveMessage));
|
||||
}
|
||||
|
||||
this.reloadDraftFolder();
|
||||
},
|
||||
this.getMessageRequestParams(FolderUserStore.draftFolder())
|
||||
);
|
||||
}
|
||||
|
@ -578,63 +628,6 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
}
|
||||
}
|
||||
|
||||
sendMessageResponse(iError, data) {
|
||||
|
||||
this.sending(false);
|
||||
|
||||
if (this.modalVisibility()) {
|
||||
if (iError) {
|
||||
if (Notification.CantSaveMessage === iError) {
|
||||
this.sendSuccessButSaveError(true);
|
||||
this.savedErrorDesc(i18n('COMPOSE/SAVED_ERROR_ON_SEND').trim());
|
||||
} else {
|
||||
this.sendError(true);
|
||||
this.sendErrorDesc(getNotification(iError, data && data.ErrorMessage)
|
||||
|| getNotification(Notification.CantSendMessage));
|
||||
}
|
||||
} else {
|
||||
this.closeCommand && this.closeCommand();
|
||||
}
|
||||
}
|
||||
|
||||
this.reloadDraftFolder();
|
||||
}
|
||||
|
||||
saveMessageResponse(iError, oData) {
|
||||
let result = false;
|
||||
|
||||
this.saving(false);
|
||||
|
||||
if (!iError) {
|
||||
if (oData.Result.NewFolder && oData.Result.NewUid) {
|
||||
result = true;
|
||||
|
||||
if (this.bFromDraft) {
|
||||
const message = MessageUserStore.message();
|
||||
if (message && this.draftFolder() === message.folder && this.draftUid() === message.uid) {
|
||||
MessageUserStore.message(null);
|
||||
}
|
||||
}
|
||||
|
||||
this.draftFolder(oData.Result.NewFolder);
|
||||
this.draftUid(oData.Result.NewUid);
|
||||
|
||||
this.savedTime(new Date);
|
||||
|
||||
if (this.bFromDraft) {
|
||||
setFolderHash(this.draftFolder(), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
this.savedError(true);
|
||||
this.savedErrorDesc(getNotification(Notification.CantSaveMessage));
|
||||
}
|
||||
|
||||
this.reloadDraftFolder();
|
||||
}
|
||||
|
||||
onHide() {
|
||||
// Stop autosave
|
||||
clearTimeout(this.iTimer);
|
||||
|
|
|
@ -90,7 +90,7 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
|
||||
this.bDropPageAfterDelete = false;
|
||||
|
||||
// this.saveCommandDebounce = _.debounce(this.saveCommand.bind(this), 1000);
|
||||
// this.saveCommandDebounce = this.saveCommand.bind(this).debounce(1000);
|
||||
|
||||
const
|
||||
// propertyFocused = property => !property.isValid() && !property.focused(),
|
||||
|
@ -382,23 +382,15 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
|
||||
deleteSelectedContacts() {
|
||||
if (this.contactsCheckedOrSelected().length) {
|
||||
Remote.contactsDelete(this.deleteResponse.bind(this), this.contactsCheckedOrSelectedUids());
|
||||
|
||||
this.removeCheckedOrSelectedContactsFromList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {int} iError
|
||||
* @param {FetchJsonDefaultResponse} oData
|
||||
*/
|
||||
deleteResponse(iError, oData) {
|
||||
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);
|
||||
setTimeout(() => this.reloadContactList(this.bDropPageAfterDelete), 500);
|
||||
}
|
||||
}, this.contactsCheckedOrSelectedUids());
|
||||
|
||||
this.removeCheckedOrSelectedContactsFromList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,25 +187,7 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
this.testing(true);
|
||||
|
||||
Remote.testConnectionForDomain(
|
||||
this.onTestConnectionResponse.bind(this),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
whiteListCommand() {
|
||||
this.page('white-list');
|
||||
}
|
||||
|
||||
backCommand() {
|
||||
this.page('main');
|
||||
}
|
||||
|
||||
sieveCommand() {
|
||||
this.sieveSettings(!this.sieveSettings());
|
||||
this.clearTesting();
|
||||
}
|
||||
|
||||
onTestConnectionResponse(iError, oData) {
|
||||
(iError, oData) => {
|
||||
this.testing(false);
|
||||
if (iError) {
|
||||
this.testingImapError(true);
|
||||
|
@ -246,6 +228,22 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
this.sieveSettings(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
whiteListCommand() {
|
||||
this.page('white-list');
|
||||
}
|
||||
|
||||
backCommand() {
|
||||
this.page('main');
|
||||
}
|
||||
|
||||
sieveCommand() {
|
||||
this.sieveSettings(!this.sieveSettings());
|
||||
this.clearTesting();
|
||||
}
|
||||
|
||||
onDomainCreateOrSaveResponse(iError) {
|
||||
|
|
|
@ -14,8 +14,6 @@ class PluginPopupView extends AbstractViewPopup {
|
|||
constructor() {
|
||||
super('Plugin');
|
||||
|
||||
this.onPluginSettingsUpdateResponse = this.onPluginSettingsUpdateResponse.bind(this);
|
||||
|
||||
this.addObservables({
|
||||
saveError: '',
|
||||
name: '',
|
||||
|
@ -50,15 +48,11 @@ class PluginPopupView extends AbstractViewPopup {
|
|||
});
|
||||
|
||||
this.saveError('');
|
||||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
|
||||
}
|
||||
|
||||
onPluginSettingsUpdateResponse(iError) {
|
||||
if (iError) {
|
||||
this.saveError(getNotification(iError));
|
||||
} else {
|
||||
this.cancelCommand();
|
||||
}
|
||||
Remote.pluginSettingsUpdate(iError =>
|
||||
iError
|
||||
? this.saveError(getNotification(iError))
|
||||
: this.cancelCommand()
|
||||
, list);
|
||||
}
|
||||
|
||||
onShow(oPlugin) {
|
||||
|
|
|
@ -263,8 +263,6 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
|
||||
addEventListener('mailbox.message-view.toggle-full-screen', () => this.toggleFullScreen());
|
||||
|
||||
this.attachmentPreview = this.attachmentPreview.bind(this);
|
||||
|
||||
decorateKoCommands(this, {
|
||||
closeMessageCommand: 1,
|
||||
messageEditCommand: self => self.messageVisibility(),
|
||||
|
@ -313,57 +311,6 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
this.oHeaderDom && this.viewBodyTopValue(this.message() ? this.oHeaderDom.offsetHeight : 0);
|
||||
}
|
||||
|
||||
// displayMailToPopup(sMailToUrl) {
|
||||
// sMailToUrl = sMailToUrl.replace(/\?.+$/, '');
|
||||
//
|
||||
// var
|
||||
// sResult = '',
|
||||
// aTo = [],
|
||||
// EmailModel = require('Model/Email').default,
|
||||
// fParseEmailLine = function(sLine) {
|
||||
// return sLine ? [decodeURIComponent(sLine)].map(sItem => {
|
||||
// var oEmailModel = new EmailModel();
|
||||
// oEmailModel.parse(sItem);
|
||||
// return oEmailModel.email ? oEmailModel : null;
|
||||
// }).filter(v => v) : null;
|
||||
// }
|
||||
// ;
|
||||
//
|
||||
// aTo = fParseEmailLine(sMailToUrl);
|
||||
// sResult = aTo && aTo[0] ? aTo[0].email : '';
|
||||
//
|
||||
// return sResult;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param {Object} oAttachment
|
||||
* @returns {boolean}
|
||||
*/
|
||||
attachmentPreview(/*attachment*/) {
|
||||
/*
|
||||
if (attachment && attachment.isImage() && !attachment.isLinked && this.message() && this.message().attachments()) {
|
||||
const items = this.message().attachments.map(item => {
|
||||
if (item && !item.isLinked && item.isImage()) {
|
||||
if (item === attachment) {
|
||||
index = listIndex;
|
||||
}
|
||||
++listIndex;
|
||||
return {
|
||||
src: item.linkPreview(),
|
||||
msrc: item.linkThumbnail(),
|
||||
title: item.fileName
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}).filter(v => v);
|
||||
|
||||
if (items.length) {
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
onBuild(dom) {
|
||||
this.fullScreenMode.subscribe(value => value && this.message() && AppUserStore.focusedState(Scope.MessageView));
|
||||
|
||||
|
@ -476,10 +423,9 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
this.initShortcuts();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
escShortcuts() {
|
||||
initShortcuts() {
|
||||
// exit fullscreen, back
|
||||
shortcuts.add('escape,backspace', '', Scope.MessageView, () => {
|
||||
if (this.viewModelVisible && this.message()) {
|
||||
const preview = SettingsUserStore.usePreviewPane();
|
||||
if (this.fullScreenMode()) {
|
||||
|
@ -498,11 +444,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
initShortcuts() {
|
||||
// exit fullscreen, back
|
||||
shortcuts.add('escape,backspace', '', Scope.MessageView, this.escShortcuts.bind(this));
|
||||
});
|
||||
|
||||
// fullscreen
|
||||
shortcuts.add('enter,open', '', Scope.MessageView, () => {
|
||||
|
|
Loading…
Reference in a new issue