Bugfix: compose popup had two autosave timers

This commit is contained in:
djmaze 2021-03-17 10:03:57 +01:00
parent 845483d127
commit 8157692a29

View file

@ -314,20 +314,6 @@ class ComposePopupView extends AbstractViewPopup {
this.resizeObserver = new ResizeObserver(this.resizerTrigger.throttle(50).bind(this)); this.resizeObserver = new ResizeObserver(this.resizerTrigger.throttle(50).bind(this));
setInterval(() => {
if (
this.modalVisibility() &&
!FolderUserStore.draftFolderNotEnabled() &&
SettingsUserStore.allowDraftAutosave() &&
!this.isEmptyForm(false) &&
!this.saving() &&
!this.sending() &&
!this.savedError()
) {
this.saveCommand();
}
}, 120000);
decorateKoCommands(this, { decorateKoCommands(this, {
sendCommand: self => self.canBeSentOrSaved(), sendCommand: self => self.canBeSentOrSaved(),
saveCommand: self => self.canBeSentOrSaved(), saveCommand: self => self.canBeSentOrSaved(),
@ -499,29 +485,22 @@ class ComposePopupView extends AbstractViewPopup {
} }
} }
autosaveFunction() {
if (
this.modalVisibility() &&
!FolderUserStore.draftFolderNotEnabled() &&
SettingsUserStore.allowDraftAutosave() &&
!this.isEmptyForm(false) &&
!this.saving() &&
!this.sending() &&
!this.savedError()
) {
this.saveCommand();
}
this.autosaveStart();
}
autosaveStart() { autosaveStart() {
clearTimeout(this.iTimer); clearTimeout(this.iTimer);
this.iTimer = setTimeout(()=>this.autosaveFunction(), 60000); this.iTimer = setTimeout(()=>{
} if (this.modalVisibility()
&& !FolderUserStore.draftFolderNotEnabled()
&& SettingsUserStore.allowDraftAutosave()
&& !this.isEmptyForm(false)
&& !this.saving()
&& !this.sending()
&& !this.savedError()
) {
this.saveCommand();
}
autosaveStop() { this.autosaveStart();
clearTimeout(this.iTimer); }, 60000);
} }
emailsSource(oData, fResponse) { emailsSource(oData, fResponse) {
@ -664,12 +643,12 @@ class ComposePopupView extends AbstractViewPopup {
} }
onHide() { onHide() {
this.autosaveStop(); // Stop autosave
clearTimeout(this.iTimer);
if (!this.bSkipNextHide) { AppUserStore.composeInEdit(this.bSkipNextHide);
AppUserStore.composeInEdit(false);
this.reset(); this.bSkipNextHide || this.reset();
}
this.bSkipNextHide = false; this.bSkipNextHide = false;
@ -822,8 +801,6 @@ class ComposePopupView extends AbstractViewPopup {
* @param {string=} sCustomPlainText = null * @param {string=} sCustomPlainText = null
*/ */
initOnShow(sType, oMessageOrArray, aToEmails, aCcEmails, aBccEmails, sCustomSubject, sCustomPlainText) { initOnShow(sType, oMessageOrArray, aToEmails, aCcEmails, aBccEmails, sCustomSubject, sCustomPlainText) {
AppUserStore.composeInEdit(true);
let sFrom = '', let sFrom = '',
sTo = '', sTo = '',
sCc = '', sCc = '',