mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Prepare for #1793
This commit is contained in:
parent
28a8e3c157
commit
6f2f40b983
5 changed files with 138 additions and 20 deletions
|
|
@ -66,7 +66,7 @@ export class FilterPopupView extends rl.pluginPopupView {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||||
this.folderSelectList = koComputable(() => folderListOptionsBuilder());
|
this.folderSelectList = koComputable(folderListOptionsBuilder);
|
||||||
|
|
||||||
this.selectedFolderValue.subscribe(() => this.filter().actionValueError(false));
|
this.selectedFolderValue.subscribe(() => this.filter().actionValueError(false));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -457,10 +457,21 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
this.from(IdentityUserStore()[0].formattedName());
|
this.from(IdentityUserStore()[0].formattedName());
|
||||||
}
|
}
|
||||||
|
|
||||||
sendCommand() {
|
sentFolder()
|
||||||
const identity = this.currentIdentity();
|
{
|
||||||
let sSentFolder = identity?.sentFolder?.() || FolderUserStore.sentFolder();
|
let sSentFolder = this.currentIdentity()?.sentFolder?.() || FolderUserStore.sentFolder();
|
||||||
|
if (SettingsUserStore.replySameFolder()) {
|
||||||
|
if (
|
||||||
|
3 === arrayLength(this.aDraftInfo) &&
|
||||||
|
this.aDraftInfo[2]?.length
|
||||||
|
) {
|
||||||
|
sSentFolder = this.aDraftInfo[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UNUSED_OPTION_VALUE === sSentFolder ? null : sSentFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendCommand() {
|
||||||
this.attachmentsInProcessError(false);
|
this.attachmentsInProcessError(false);
|
||||||
this.attachmentsInErrorError(false);
|
this.attachmentsInErrorError(false);
|
||||||
this.emptyToError(false);
|
this.emptyToError(false);
|
||||||
|
|
@ -478,16 +489,8 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError()) {
|
if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError()) {
|
||||||
if (SettingsUserStore.replySameFolder()) {
|
const sSentFolder = this.sentFolder();
|
||||||
if (
|
if ('' === sSentFolder) {
|
||||||
3 === arrayLength(this.aDraftInfo) &&
|
|
||||||
this.aDraftInfo[2]?.length
|
|
||||||
) {
|
|
||||||
sSentFolder = this.aDraftInfo[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sSentFolder) {
|
|
||||||
showScreenPopup(FolderSystemPopupView, [FolderType.Sent]);
|
showScreenPopup(FolderSystemPopupView, [FolderType.Sent]);
|
||||||
} else {
|
} else {
|
||||||
const sendError = e => {
|
const sendError = e => {
|
||||||
|
|
@ -507,8 +510,6 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
this.sendError(false);
|
this.sendError(false);
|
||||||
this.sending(true);
|
this.sending(true);
|
||||||
|
|
||||||
sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder;
|
|
||||||
|
|
||||||
const sendMessage = params => {
|
const sendMessage = params => {
|
||||||
Remote.request('SendMessage',
|
Remote.request('SendMessage',
|
||||||
(iError, data) => {
|
(iError, data) => {
|
||||||
|
|
@ -538,7 +539,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
this.sendError(true);
|
this.sendError(true);
|
||||||
sendFailed(iError, data);
|
sendFailed(iError, data);
|
||||||
// Remove remembered passphrase as it could be wrong
|
// Remove remembered passphrase as it could be wrong
|
||||||
let key = ('S/MIME' === params.sign) ? identity : null;
|
let key = ('S/MIME' === params.sign) ? this.currentIdentity() : null;
|
||||||
params.signFingerprint
|
params.signFingerprint
|
||||||
&& this.signOptions.forEach(option => ('GnuPG' === option[0]) && (key = option[1]));
|
&& this.signOptions.forEach(option => ('GnuPG' === option[0]) && (key = option[1]));
|
||||||
key && Passphrases.delete(key);
|
key && Passphrases.delete(key);
|
||||||
|
|
@ -560,10 +561,9 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
setFolderETag(this.draftsFolder(), '');
|
setFolderETag(this.draftsFolder(), '');
|
||||||
setFolderETag(sSentFolder, '');
|
setFolderETag(params.saveFolder, '');
|
||||||
if (3 === arrayLength(this.aDraftInfo)) {
|
if (3 === arrayLength(this.aDraftInfo)) {
|
||||||
const folder = this.aDraftInfo[2];
|
setFolderETag(this.aDraftInfo[2], '');
|
||||||
setFolderETag(folder, '');
|
|
||||||
}
|
}
|
||||||
reloadDraftFolder();
|
reloadDraftFolder();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
20
plugins/send-save-in/LICENSE
Normal file
20
plugins/send-save-in/LICENSE
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 RainLoop Team
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
23
plugins/send-save-in/index.php
Normal file
23
plugins/send-save-in/index.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SendSaveInPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
|
{
|
||||||
|
// use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
|
const
|
||||||
|
NAME = 'Send Save In',
|
||||||
|
AUTHOR = 'SnappyMail',
|
||||||
|
URL = 'https://snappymail.eu/',
|
||||||
|
VERSION = '0.0',
|
||||||
|
RELEASE = '2024-10-08',
|
||||||
|
REQUIRED = '2.38.1',
|
||||||
|
CATEGORY = 'General',
|
||||||
|
LICENSE = 'MIT',
|
||||||
|
DESCRIPTION = 'When composing a message, select the save folder';
|
||||||
|
|
||||||
|
public function Init() : void
|
||||||
|
{
|
||||||
|
// $this->UseLangs(true); // start use langs folder
|
||||||
|
$this->addJs('savein.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
75
plugins/send-save-in/savein.js
Normal file
75
plugins/send-save-in/savein.js
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
(rl => {
|
||||||
|
const templateId = 'PopupsCompose',
|
||||||
|
folderListOptionsBuilder = () => {
|
||||||
|
const
|
||||||
|
aResult = [{
|
||||||
|
id: '',
|
||||||
|
name: '',
|
||||||
|
system: false,
|
||||||
|
disabled: false
|
||||||
|
}],
|
||||||
|
sDeepPrefix = '\u00A0\u00A0\u00A0',
|
||||||
|
showUnsubscribed = true/*!SettingsUserStore.hideUnsubscribed()*/,
|
||||||
|
|
||||||
|
foldersWalk = folders => {
|
||||||
|
folders.forEach(oItem => {
|
||||||
|
if (showUnsubscribed || oItem.hasSubscriptions() || !oItem.exists) {
|
||||||
|
aResult.push({
|
||||||
|
id: oItem.fullName,
|
||||||
|
name: sDeepPrefix.repeat(oItem.deep) + oItem.detailedName(),
|
||||||
|
system: false,
|
||||||
|
disabled: !oItem.selectable()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oItem.subFolders.length) {
|
||||||
|
foldersWalk(oItem.subFolders());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// FolderUserStore.folderList()
|
||||||
|
foldersWalk(rl.app.folderList() || []);
|
||||||
|
|
||||||
|
return aResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
let oldSentFolderFn;
|
||||||
|
|
||||||
|
addEventListener('rl-view-model.create', e => {
|
||||||
|
if (templateId === e.detail.viewModelTemplateID) {
|
||||||
|
const view = e.detail; // ComposePopupView
|
||||||
|
|
||||||
|
view.sentFolderValue = ko.observable('');
|
||||||
|
view.sentFolderSelectList = ko.computed(folderListOptionsBuilder, {'pure':true});
|
||||||
|
view.defaultOptionsAfterRender = (domItem, item) =>
|
||||||
|
item && undefined !== item.disabled && domItem?.classList.toggle('disabled', domItem.disabled = item.disabled);
|
||||||
|
|
||||||
|
oldSentFolderFn = view.sentFolder.bind(view);
|
||||||
|
view.sentFolder = () => view.sentFolderValue() || oldSentFolderFn();
|
||||||
|
|
||||||
|
document.getElementById(templateId).content.querySelector('.b-header tbody').append(Element.fromHTML(`
|
||||||
|
<tr>
|
||||||
|
<td>Store in</td>
|
||||||
|
<td>
|
||||||
|
<select class="span3" data-bind="options: sentFolderSelectList, value: sentFolderValue,
|
||||||
|
optionsText: 'name', optionsValue: 'id', optionsAfterRender: defaultOptionsAfterRender"></select>
|
||||||
|
(When send, store a copy of the message in the selected folder)
|
||||||
|
</td>
|
||||||
|
</tr>`));
|
||||||
|
|
||||||
|
view.currentIdentity.subscribe(()=>{
|
||||||
|
view.sentFolderValue(oldSentFolderFn());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addEventListener('rl-vm-visible', e => {
|
||||||
|
if (templateId === e.detail.viewModelTemplateID) {
|
||||||
|
const view = e.detail; // ComposePopupView
|
||||||
|
view.sentFolderValue(oldSentFolderFn());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})(window.rl);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue