Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 6f2f40b

Browse files
author
the-djmaze
committed
Prepare for #1793
1 parent 28a8e3c commit 6f2f40b

File tree

5 files changed

+138
-20
lines changed

5 files changed

+138
-20
lines changed

dev/Sieve/View/Filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class FilterPopupView extends rl.pluginPopupView {
6666
});
6767

6868
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
69-
this.folderSelectList = koComputable(() => folderListOptionsBuilder());
69+
this.folderSelectList = koComputable(folderListOptionsBuilder);
7070

7171
this.selectedFolderValue.subscribe(() => this.filter().actionValueError(false));
7272

dev/View/Popup/Compose.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,21 @@ export class ComposePopupView extends AbstractViewPopup {
457457
this.from(IdentityUserStore()[0].formattedName());
458458
}
459459

460-
sendCommand() {
461-
const identity = this.currentIdentity();
462-
let sSentFolder = identity?.sentFolder?.() || FolderUserStore.sentFolder();
460+
sentFolder()
461+
{
462+
let sSentFolder = this.currentIdentity()?.sentFolder?.() || FolderUserStore.sentFolder();
463+
if (SettingsUserStore.replySameFolder()) {
464+
if (
465+
3 === arrayLength(this.aDraftInfo) &&
466+
this.aDraftInfo[2]?.length
467+
) {
468+
sSentFolder = this.aDraftInfo[2];
469+
}
470+
}
471+
return UNUSED_OPTION_VALUE === sSentFolder ? null : sSentFolder;
472+
}
463473

474+
sendCommand() {
464475
this.attachmentsInProcessError(false);
465476
this.attachmentsInErrorError(false);
466477
this.emptyToError(false);
@@ -478,16 +489,8 @@ export class ComposePopupView extends AbstractViewPopup {
478489
}
479490

480491
if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError()) {
481-
if (SettingsUserStore.replySameFolder()) {
482-
if (
483-
3 === arrayLength(this.aDraftInfo) &&
484-
this.aDraftInfo[2]?.length
485-
) {
486-
sSentFolder = this.aDraftInfo[2];
487-
}
488-
}
489-
490-
if (!sSentFolder) {
492+
const sSentFolder = this.sentFolder();
493+
if ('' === sSentFolder) {
491494
showScreenPopup(FolderSystemPopupView, [FolderType.Sent]);
492495
} else {
493496
const sendError = e => {
@@ -507,8 +510,6 @@ export class ComposePopupView extends AbstractViewPopup {
507510
this.sendError(false);
508511
this.sending(true);
509512

510-
sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder;
511-
512513
const sendMessage = params => {
513514
Remote.request('SendMessage',
514515
(iError, data) => {
@@ -538,7 +539,7 @@ export class ComposePopupView extends AbstractViewPopup {
538539
this.sendError(true);
539540
sendFailed(iError, data);
540541
// Remove remembered passphrase as it could be wrong
541-
let key = ('S/MIME' === params.sign) ? identity : null;
542+
let key = ('S/MIME' === params.sign) ? this.currentIdentity() : null;
542543
params.signFingerprint
543544
&& this.signOptions.forEach(option => ('GnuPG' === option[0]) && (key = option[1]));
544545
key && Passphrases.delete(key);
@@ -560,10 +561,9 @@ export class ComposePopupView extends AbstractViewPopup {
560561
this.close();
561562
}
562563
setFolderETag(this.draftsFolder(), '');
563-
setFolderETag(sSentFolder, '');
564+
setFolderETag(params.saveFolder, '');
564565
if (3 === arrayLength(this.aDraftInfo)) {
565-
const folder = this.aDraftInfo[2];
566-
setFolderETag(folder, '');
566+
setFolderETag(this.aDraftInfo[2], '');
567567
}
568568
reloadDraftFolder();
569569
},

plugins/send-save-in/LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 RainLoop Team
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

plugins/send-save-in/index.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
class SendSaveInPlugin extends \RainLoop\Plugins\AbstractPlugin
4+
{
5+
// use \MailSo\Log\Inherit;
6+
7+
const
8+
NAME = 'Send Save In',
9+
AUTHOR = 'SnappyMail',
10+
URL = 'https://snappymail.eu/',
11+
VERSION = '0.0',
12+
RELEASE = '2024-10-08',
13+
REQUIRED = '2.38.1',
14+
CATEGORY = 'General',
15+
LICENSE = 'MIT',
16+
DESCRIPTION = 'When composing a message, select the save folder';
17+
18+
public function Init() : void
19+
{
20+
// $this->UseLangs(true); // start use langs folder
21+
$this->addJs('savein.js');
22+
}
23+
}

plugins/send-save-in/savein.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
(rl => {
2+
const templateId = 'PopupsCompose',
3+
folderListOptionsBuilder = () => {
4+
const
5+
aResult = [{
6+
id: '',
7+
name: '',
8+
system: false,
9+
disabled: false
10+
}],
11+
sDeepPrefix = '\u00A0\u00A0\u00A0',
12+
showUnsubscribed = true/*!SettingsUserStore.hideUnsubscribed()*/,
13+
14+
foldersWalk = folders => {
15+
folders.forEach(oItem => {
16+
if (showUnsubscribed || oItem.hasSubscriptions() || !oItem.exists) {
17+
aResult.push({
18+
id: oItem.fullName,
19+
name: sDeepPrefix.repeat(oItem.deep) + oItem.detailedName(),
20+
system: false,
21+
disabled: !oItem.selectable()
22+
});
23+
}
24+
25+
if (oItem.subFolders.length) {
26+
foldersWalk(oItem.subFolders());
27+
}
28+
});
29+
};
30+
31+
32+
// FolderUserStore.folderList()
33+
foldersWalk(rl.app.folderList() || []);
34+
35+
return aResult;
36+
};
37+
38+
let oldSentFolderFn;
39+
40+
addEventListener('rl-view-model.create', e => {
41+
if (templateId === e.detail.viewModelTemplateID) {
42+
const view = e.detail; // ComposePopupView
43+
44+
view.sentFolderValue = ko.observable('');
45+
view.sentFolderSelectList = ko.computed(folderListOptionsBuilder, {'pure':true});
46+
view.defaultOptionsAfterRender = (domItem, item) =>
47+
item && undefined !== item.disabled && domItem?.classList.toggle('disabled', domItem.disabled = item.disabled);
48+
49+
oldSentFolderFn = view.sentFolder.bind(view);
50+
view.sentFolder = () => view.sentFolderValue() || oldSentFolderFn();
51+
52+
document.getElementById(templateId).content.querySelector('.b-header tbody').append(Element.fromHTML(`
53+
<tr>
54+
<td>Store in</td>
55+
<td>
56+
<select class="span3" data-bind="options: sentFolderSelectList, value: sentFolderValue,
57+
optionsText: 'name', optionsValue: 'id', optionsAfterRender: defaultOptionsAfterRender"></select>
58+
(When send, store a copy of the message in the selected folder)
59+
</td>
60+
</tr>`));
61+
62+
view.currentIdentity.subscribe(()=>{
63+
view.sentFolderValue(oldSentFolderFn());
64+
});
65+
}
66+
});
67+
68+
addEventListener('rl-vm-visible', e => {
69+
if (templateId === e.detail.viewModelTemplateID) {
70+
const view = e.detail; // ComposePopupView
71+
view.sentFolderValue(oldSentFolderFn());
72+
}
73+
});
74+
75+
})(window.rl);

0 commit comments

Comments
 (0)