Skip to content

Commit d76fde3

Browse files
committed
Fix crippled contact names (RainLoop#1447)
1 parent ed56853 commit d76fde3

File tree

10 files changed

+121
-255
lines changed

10 files changed

+121
-255
lines changed

dev/App/User.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class AppUser extends AbstractApp
494494
if (item.userId)
495495
{
496496
email.clear();
497-
email.mailsoParse(item.userId.userid);
497+
email.parse(item.userId.userid);
498498
if (email.validate())
499499
{
500500
aEmails.push(email.email);

dev/Common/Utils.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,14 +1517,14 @@ export function resizeAndCrop(url, value, fCallback)
15171517

15181518
/**
15191519
* @param {string} mailToUrl
1520-
* @param {Function} PopupComposeVoreModel
1520+
* @param {Function} PopupComposeViewModel
15211521
* @returns {boolean}
15221522
*/
1523-
export function mailToHelper(mailToUrl, PopupComposeVoreModel)
1523+
export function mailToHelper(mailToUrl, PopupComposeViewModel)
15241524
{
15251525
if (mailToUrl && 'mailto:' === mailToUrl.toString().substr(0, 7).toLowerCase())
15261526
{
1527-
if (!PopupComposeVoreModel)
1527+
if (!PopupComposeViewModel)
15281528
{
15291529
return true;
15301530
}
@@ -1540,28 +1540,22 @@ export function mailToHelper(mailToUrl, PopupComposeVoreModel)
15401540
const
15411541
email = mailToUrl.replace(/\?.+$/, ''),
15421542
query = mailToUrl.replace(/^[^\?]*\?/, ''),
1543-
EmailModel = require('Model/Email').default,
1544-
emailObj = new EmailModel(),
1545-
fParseEmailLine = (line) => (line ? _.compact(_.map(decodeURIComponent(line).split(/[,]/), (item) => {
1546-
emailObj.clear();
1547-
emailObj.mailsoParse(item);
1548-
return '' !== emailObj.email ? emailObj : null;
1549-
})) : null);
1550-
1551-
to = fParseEmailLine(email);
1543+
EmailModel = require('Model/Email').default;
1544+
1545+
to = EmailModel.parseEmailLine(email);
15521546
params = simpleQueryParser(query);
15531547

15541548
if (!isUnd(params.cc))
15551549
{
1556-
cc = fParseEmailLine(decodeURIComponent(params.cc));
1550+
cc = EmailModel.parseEmailLine(decodeURIComponent(params.cc));
15571551
}
15581552

15591553
if (!isUnd(params.bcc))
15601554
{
1561-
bcc = fParseEmailLine(decodeURIComponent(params.bcc));
1555+
bcc = EmailModel.parseEmailLine(decodeURIComponent(params.bcc));
15621556
}
15631557

1564-
require('Knoin/Knoin').showScreenPopup(PopupComposeVoreModel, [
1558+
require('Knoin/Knoin').showScreenPopup(PopupComposeViewModel, [
15651559
ComposeType.Empty, null, to, cc, bcc,
15661560
isUnd(params.subject) ? null : pString(decodeURIComponent(params.subject)),
15671561
isUnd(params.body) ? null : plainToHtml(pString(decodeURIComponent(params.body)))

dev/External/ko.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ ko.bindingHandlers.emailsTags = {
884884
fValue = fValueAccessor(),
885885
fAllBindings = fAllBindingsAccessor(),
886886
fAutoCompleteSource = fAllBindings.autoCompleteSource || null,
887+
inputDelimiters = [',', ';', '\n'],
887888
fFocusCallback = (value) => {
888889
if (fValue && fValue.focused)
889890
{
@@ -895,26 +896,26 @@ ko.bindingHandlers.emailsTags = {
895896
parseOnBlur: true,
896897
allowDragAndDrop: true,
897898
focusCallback: fFocusCallback,
898-
inputDelimiters: [',', ';', '\n'],
899+
inputDelimiters: inputDelimiters,
899900
autoCompleteSource: fAutoCompleteSource,
900-
// elementHook: (el, item) => {
901-
// if (el && item)
902-
// {
903-
// el.addClass('pgp');
904-
// }
905-
// },
906-
parseHook: (input) => _.map(input, (inputValue) => {
907-
const value = Utils.trim(inputValue);
908-
if ('' !== value)
909-
{
910-
const email = new EmailModel();
911-
email.mailsoParse(value);
912-
return [email.toLine(false), email];
901+
splitHook: (value) => {
902+
const v = Utils.trim(value);
903+
if (v && -1 < inputDelimiters.indexOf(v.substr(-1))) {
904+
return EmailModel.splitEmailLine(value);
913905
}
914-
return [value, null];
915-
916-
}),
917-
'change': (event) => {
906+
return null;
907+
},
908+
parseHook: (input) => _.map(
909+
_.flatten(_.map(
910+
input,
911+
(inputValue) => {
912+
const values = EmailModel.parseEmailLine(inputValue);
913+
return values.length ? values : inputValue;
914+
}
915+
)),
916+
(item) => (_.isObject(item) ? [item.toLine(false), item] : [item, null])
917+
),
918+
change: (event) => {
918919
$el.data('EmailsTagsValue', event.target.value);
919920
fValue(event.target.value);
920921
}

0 commit comments

Comments
 (0)