Commit e123c690 authored by JC Brand's avatar JC Brand

Add autocomplete support for occupants with only a JID

parent 41a42fe2
...@@ -76825,8 +76825,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76825,8 +76825,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'match_current_word': true, 'match_current_word': true,
'match_on_tab': true, 'match_on_tab': true,
'list': () => this.model.occupants.map(o => ({ 'list': () => this.model.occupants.map(o => ({
'label': o.get('nick'), 'label': o.getDisplayName(),
'value': `@${o.get('nick')}` 'value': `@${o.getDisplayName()}`
})), })),
'filter': _converse.FILTER_STARTSWITH, 'filter': _converse.FILTER_STARTSWITH,
'trigger_on_at': true 'trigger_on_at': true
...@@ -78617,7 +78617,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } ...@@ -78617,7 +78617,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
}, },
getReferenceForMention(mention, index) { getReferenceForMention(mention, index) {
const longest_match = u.getLongestSubstring(mention, this.occupants.map(o => o.get('nick'))); const longest_match = u.getLongestSubstring(mention, this.occupants.map(o => o.getDisplayName()));
if (!longest_match) { if (!longest_match) {
return null; return null;
...@@ -78632,6 +78632,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } ...@@ -78632,6 +78632,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
const occupant = this.occupants.findOccupant({ const occupant = this.occupants.findOccupant({
'nick': longest_match 'nick': longest_match
}) || this.occupants.findOccupant({
'jid': longest_match
}); });
if (!occupant) { if (!occupant) {
...@@ -618,7 +618,7 @@ ...@@ -618,7 +618,7 @@
'min_chars': 1, 'min_chars': 1,
'match_current_word': true, 'match_current_word': true,
'match_on_tab': true, 'match_on_tab': true,
'list': () => this.model.occupants.map(o => ({'label': o.get('nick'), 'value': `@${o.get('nick')}`})), 'list': () => this.model.occupants.map(o => ({'label': o.getDisplayName(), 'value': `@${o.getDisplayName()}`})),
'filter': _converse.FILTER_STARTSWITH, 'filter': _converse.FILTER_STARTSWITH,
'trigger_on_at': true 'trigger_on_at': true
}); });
......
...@@ -309,7 +309,10 @@ ...@@ -309,7 +309,10 @@
}, },
getReferenceForMention (mention, index) { getReferenceForMention (mention, index) {
const longest_match = u.getLongestSubstring(mention, this.occupants.map(o => o.get('nick'))); const longest_match = u.getLongestSubstring(
mention,
this.occupants.map(o => o.getDisplayName())
);
if (!longest_match) { if (!longest_match) {
return null; return null;
} }
...@@ -319,7 +322,8 @@ ...@@ -319,7 +322,8 @@
// match. // match.
return null; return null;
} }
const occupant = this.occupants.findOccupant({'nick': longest_match}); const occupant = this.occupants.findOccupant({'nick': longest_match}) ||
this.occupants.findOccupant({'jid': longest_match});
if (!occupant) { if (!occupant) {
return null; return null;
} }
...@@ -341,7 +345,7 @@ ...@@ -341,7 +345,7 @@
continue continue
} else { } else {
const match = text.slice(i+1), const match = text.slice(i+1),
ref = this.getReferenceForMention(match, i) ref = this.getReferenceForMention(match, i);
if (ref) { if (ref) {
return [text.slice(0, i) + match, ref, i] return [text.slice(0, i) + match, ref, i]
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment