Преглед на файлове

Add autocomplete support for occupants with only a JID

JC Brand преди 7 години
родител
ревизия
e123c690f0
променени са 3 файла, в които са добавени 13 реда и са изтрити 7 реда
  1. 5 3
      dist/converse.js
  2. 1 1
      src/converse-muc-views.js
  3. 7 3
      src/converse-muc.js

+ 5 - 3
dist/converse.js

@@ -76825,8 +76825,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
             'match_current_word': true,
             'match_on_tab': true,
             'list': () => this.model.occupants.map(o => ({
-              'label': o.get('nick'),
-              'value': `@${o.get('nick')}`
+              'label': o.getDisplayName(),
+              'value': `@${o.getDisplayName()}`
             })),
             'filter': _converse.FILTER_STARTSWITH,
             'trigger_on_at': true
@@ -78617,7 +78617,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
         },
 
         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) {
             return null;
@@ -78632,6 +78632,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
 
           const occupant = this.occupants.findOccupant({
             'nick': longest_match
+          }) || this.occupants.findOccupant({
+            'jid': longest_match
           });
 
           if (!occupant) {

+ 1 - 1
src/converse-muc-views.js

@@ -618,7 +618,7 @@
                         'min_chars': 1,
                         'match_current_word': 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,
                         'trigger_on_at': true
                     });

+ 7 - 3
src/converse-muc.js

@@ -309,7 +309,10 @@
                 },
 
                 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) {
                         return null;
                     }
@@ -319,7 +322,8 @@
                         // match.
                         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) {
                         return null;
                     }
@@ -341,7 +345,7 @@
                             continue
                         } else {
                             const match = text.slice(i+1),
-                                  ref = this.getReferenceForMention(match, i)
+                                  ref = this.getReferenceForMention(match, i);
                             if (ref) {
                                 return [text.slice(0, i) + match, ref, i]
                             }