lkosson / full-address-column

Thunderbird add-on to show full sender and recipient address column in message list
MIT License
39 stars 11 forks source link

[Feature request] Senders name & email alternative option #6

Closed Savasdotexe closed 2 months ago

Savasdotexe commented 3 years ago

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 (johnsmith@email.com),

lkosson commented 3 years ago

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.

Savasdotexe commented 2 years ago

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.

lkosson commented 2 years ago

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; },

Savasdotexe commented 2 years ago

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").

lkosson commented 2 years ago

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.