Cleanup FolderClearPopupView

This commit is contained in:
the-djmaze 2022-09-21 09:51:52 +02:00
parent 36c54521d7
commit 64c716ea07
2 changed files with 23 additions and 41 deletions

View file

@ -13,55 +13,42 @@ export class FolderClearPopupView extends AbstractViewPopup {
super('FolderClear');
this.addObservables({
selectedFolder: null,
clearingProcess: false,
clearingError: ''
folder: null,
clearing: false
});
this.addComputables({
dangerDescHtml: () => {
const folder = this.selectedFolder();
// return i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { FOLDER: folder ? folder.fullName.replace(folder.delimiter, ' / ') : '' });
return i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { FOLDER: folder ? folder.localName() : '' });
// const folder = this.folder();
// return i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { FOLDER: folder.fullName.replace(folder.delimiter, ' / ') });
return i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { FOLDER: this.folder()?.localName() });
}
});
decorateKoCommands(this, {
clearCommand: self => {
const folder = self.selectedFolder();
return !self.clearingProcess() && null !== folder;
}
clearCommand: self => !self.clearing()
});
}
clearCommand() {
const folderToClear = this.selectedFolder();
if (folderToClear) {
MessageUserStore.message(null);
MessagelistUserStore([]);
this.clearingProcess(true);
folderToClear.totalEmails(0);
folderToClear.unreadEmails(0);
folderToClear.hash = '';
const folder = this.folder();
if (folder) {
this.clearing(true);
Remote.request('FolderClear', iError => {
this.clearingProcess(false);
if (iError) {
this.clearingError(getNotification(iError));
} else {
MessagelistUserStore.reload(true);
this.close();
}
folder.totalEmails(0);
folder.unreadEmails(0);
MessageUserStore.message(null);
MessagelistUserStore.reload(true, true);
this.clearing(false);
iError ? alert(getNotification(iError)) : this.close();
}, {
Folder: folderToClear.fullName
Folder: folder.fullName
});
}
}
onShow(folder) {
this.clearingProcess(false);
this.selectedFolder(folder || null);
this.clearing(false);
this.folder(folder);
}
}

View file

@ -1,23 +1,18 @@
<header>
<a href="#" class="close" data-bind="click: close">×</a>
<h3>
<span data-i18n="POPUPS_CLEAR_FOLDER/TITLE_CLEAR_FOLDER" data-bind="visible: !clearingProcess()"></span>
<span data-i18n="POPUPS_CLEAR_FOLDER/TITLE_CLEARING_PROCESS" data-bind="visible: clearingProcess"></span>
</h3>
<h3 data-i18n="POPUPS_CLEAR_FOLDER/TITLE_CLEAR_FOLDER" data-bind="hidden: clearing"></h3>
<h3 data-i18n="POPUPS_CLEAR_FOLDER/TITLE_CLEARING_PROCESS" data-bind="visible: clearing"></h3>
</header>
<div class="modal-body">
<i class="fontastic" style="color:red"></i>
&nbsp;&nbsp;
&nbsp;
<strong data-i18n="[html]POPUPS_CLEAR_FOLDER/DANGER_DESC_WARNING"></strong>
<br>
<br>
<span data-bind="html: dangerDescHtml"></span>
<br>
<p data-bind="html: dangerDescHtml"></p>
<span data-i18n="[html]POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_2"></span>
</div>
<footer>
<a class="btn btn-danger" data-bind="command: clearCommand">
<i class="fontastic" data-bind="css: {'icon-spinner white': clearingProcess()}">🔥</i>
<i class="fontastic" data-bind="css: {'icon-spinner white': clearing}">🔥</i>
<span data-i18n="GLOBAL/CLEAR"></span>
</a>
</footer>