Skip to content
Permalink
Browse files

Half-fix "add to cc"

  • Loading branch information...
lamby committed Feb 26, 2019
1 parent 812d22a commit 2ab35a47b705192829c7e8737a0f0aa89230777a
Showing with 12 additions and 9 deletions.
  1. +12 −9 js/main.js
@@ -177,33 +177,36 @@ function FastMailEnhancementSuite(options) {
.prependTo(wrapper)
.on('click', function() {
var re = new RegExp(/^\[Adding (.*) to CC\]\n\n/);
var instance = FastMail.mail.screens.compose.instance;
var instance = FastMail.mail.draft;

var emails = prompt("Enter address to add to CC");
var email = prompt("Enter address to add to CC");

if (emails == null) {
if (email == null) {
return;
}

// Construct new "Cc" header.
var cc = (instance.get('cc') + ', ' + emails).replace(/^, /, '');
// Set the "Cc" header itself
var cc = instance.get('cc');
cc.push({email: email, name: null});
console.log(cc);

var body = instance.get('plainBody');
var body = instance.textBody;
var m = re.exec(body);

// If it was already there, strip first, then append to existing
// list.
if (m != null) {
body = body.replace(re, '');
emails = m[1] + " & " + emails;
emails = m[1] + " & " + email;
}

body = "[Adding " + emails + " to CC]\n\n" + body;
body = "[Adding " + email + " to CC]\n\n" + body;
console.log(body);

O.RunLoop.invoke(() => {
instance
.set('cc', cc)
.set('plainBody', body)
.set('textBody', body)
;
});
})

0 comments on commit 2ab35a4

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.