full-address-column icon indicating copy to clipboard operation
full-address-column copied to clipboard

[Feature request] Senders name & email alternative option

Open Savasdotexe opened this issue 3 years ago • 5 comments

Instead of including another column for the name, it would be much simpler if the senders name and email were together, for example:

John Smith ([email protected]),

Savasdotexe avatar Apr 21 '21 18:04 Savasdotexe

I'd rather have addon do one thing and be as simple as possible. Shouldn't be that hard to fork and customize it, though - all the relevant code is in customcol.js, in getCellText function.

lkosson avatar Apr 22 '21 05:04 lkosson

Hello Ikosson, me again!

I understand.

I managed to fork it and learn how to rename everything, but looking at customcol.js and getCellText function, I'm still unsure how to do it (as in I cannot interpret the code).

If it's not too much trouble, can you have a look or provide me with an example and I can carry on with the rest.

Savasdotexe avatar Oct 27 '21 16:10 Savasdotexe

In customcol.js the following line

formatAddress(acc, val) { return (acc == "" ? "" : acc + ", ") + (val.includes(">") ? [...val.matchAll(/[^<]+(?=>)/g)].join(', ') : val); },

should be something like

formatAddress(acc, val) { return (acc == "" ? "" : acc + ", ") + (val.includes(">") ? val + " (" + [...val.matchAll(/[^<]+(?=>)/g)].join(', ') + ")" : val); },

Similarly, you should replace

getAddress(aHeader) { return aHeader.author.replace(/.*</, "").replace(/>.*/, ""); },

with just

getAddress(aHeader) { return aHeader.author; },

lkosson avatar Oct 29 '21 06:10 lkosson

That's awesome, thank you!

Here's the fork btw - https://github.com/Savasdotexe/namenaddress-column/ I've also added you as an author, I hope that is appropriate and you do not mind? Seeing as you've done pretty much everything.

There is just one issue that I've noticed. Some names are coming out skewed, like for example - https://i.imgur.com/oWoznw3.png

The default 'From' column is just a reference to compare the sender name. It does not seem to be due to special characters as I noticed a few others with normal characters were similar issue even though the email address header itself reads it fine. Some names are also in quotes ( like "Name").

Savasdotexe avatar Oct 31 '21 12:10 Savasdotexe

This looks like the same issue as #4 (third paragraph). Usually Thunderbird automatically decodes MIME Encoded-Word back to readable form, but in some rare cases like here it doesn't. So far I didn't manage to reproduce the issue on any of my mails, so I can't really test and fix it.

You can try using decodeWords method from libmime.js before passing a result from your getAddress method. It should handle such cases.

lkosson avatar Nov 02 '21 05:11 lkosson