2022-10-31 05:19:52 +08:00
|
|
|
import { addObservablesTo, addComputablesTo } from 'External/ko';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { i18n, getNotification } from 'Common/Translator';
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
import { MessageUserStore } from 'Stores/User/Message';
|
2022-02-24 02:26:52 +08:00
|
|
|
import { MessagelistUserStore } from 'Stores/User/Messagelist';
|
2014-08-25 15:10:51 +08:00
|
|
|
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/User/Fetch';
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2021-02-19 19:09:20 +08:00
|
|
|
import { decorateKoCommands } from 'Knoin/Knoin';
|
2021-01-24 17:25:23 +08:00
|
|
|
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
|
|
|
|
2022-02-24 21:01:41 +08:00
|
|
|
export class FolderClearPopupView extends AbstractViewPopup {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-01-24 17:25:23 +08:00
|
|
|
super('FolderClear');
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2022-10-31 05:19:52 +08:00
|
|
|
addObservablesTo(this, {
|
2022-09-21 15:51:52 +08:00
|
|
|
folder: null,
|
|
|
|
clearing: false
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2022-10-31 05:19:52 +08:00
|
|
|
addComputablesTo(this, {
|
2022-02-21 22:36:34 +08:00
|
|
|
dangerDescHtml: () => {
|
2022-09-21 15:51:52 +08:00
|
|
|
// 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() });
|
2022-02-21 22:36:34 +08:00
|
|
|
}
|
2020-10-26 19:54:03 +08:00
|
|
|
});
|
2016-09-10 06:38:16 +08:00
|
|
|
|
2021-02-19 19:09:20 +08:00
|
|
|
decorateKoCommands(this, {
|
2022-09-21 15:51:52 +08:00
|
|
|
clearCommand: self => !self.clearing()
|
2021-02-19 19:09:20 +08:00
|
|
|
});
|
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-09-10 06:38:16 +08:00
|
|
|
clearCommand() {
|
2022-09-21 15:51:52 +08:00
|
|
|
const folder = this.folder();
|
|
|
|
if (folder) {
|
|
|
|
this.clearing(true);
|
2021-12-03 06:15:24 +08:00
|
|
|
Remote.request('FolderClear', iError => {
|
2022-09-21 15:51:52 +08:00
|
|
|
folder.totalEmails(0);
|
|
|
|
folder.unreadEmails(0);
|
|
|
|
MessageUserStore.message(null);
|
|
|
|
MessagelistUserStore.reload(true, true);
|
|
|
|
this.clearing(false);
|
|
|
|
iError ? alert(getNotification(iError)) : this.close();
|
2021-12-03 06:15:24 +08:00
|
|
|
}, {
|
2023-01-25 01:58:25 +08:00
|
|
|
folder: folder.fullName
|
2021-12-03 06:15:24 +08:00
|
|
|
});
|
2016-09-10 06:38:16 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
onShow(folder) {
|
2022-09-21 15:51:52 +08:00
|
|
|
this.clearing(false);
|
|
|
|
this.folder(folder);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|