浏览代码

Bugfix. Need to pass in group name since `this` is undefined

JC Brand 4 年之前
父节点
当前提交
d71ab6d30d
共有 3 个文件被更改,包括 6 次插入8 次删除
  1. 0 1
      src/plugins/rosterview/index.js
  2. 1 1
      src/plugins/rosterview/templates/roster.js
  3. 5 6
      src/plugins/rosterview/utils.js

+ 0 - 1
src/plugins/rosterview/index.js

@@ -1,5 +1,4 @@
 /**
- * @module converse-rosterview
  * @copyright 2020, the Converse.js contributors
  * @license Mozilla Public License (MPLv2)
  */

+ 1 - 1
src/plugins/rosterview/templates/roster.js

@@ -56,7 +56,7 @@ export default () => {
         <converse-roster-filter></converse-roster-filter>
         <div class="list-container roster-contacts">
             ${ repeat(groupnames, n => n, name => {
-                const contacts = contacts_map[name].filter(c => shouldShowContact(c));
+                const contacts = contacts_map[name].filter(c => shouldShowContact(c, name));
                 contacts.sort(contactsComparator);
                 if (contacts.length) {
                     return tpl_group({

+ 5 - 6
src/plugins/rosterview/utils.js

@@ -16,8 +16,7 @@ export function toggleGroup (ev, name) {
     }
 }
 
-
-export function isContactFiltered (contact) {
+export function isContactFiltered (contact, groupname) {
     const filter = _converse.roster_filter;
     const type = filter.get('filter_type');
     const q = (type === 'state') ?
@@ -28,7 +27,7 @@ export function isContactFiltered (contact) {
 
     if (type === 'state') {
         const sticky_groups = [_converse.HEADER_REQUESTING_CONTACTS, _converse.HEADER_UNREAD];
-        if (sticky_groups.includes(this.model.get('name'))) {
+        if (sticky_groups.includes(groupname)) {
             // When filtering by chat state, we still want to
             // show sticky groups, even though they don't
             // match the state in question.
@@ -45,18 +44,18 @@ export function isContactFiltered (contact) {
     }
 }
 
-export function shouldShowContact (contact) {
+export function shouldShowContact (contact, groupname) {
     const chat_status = contact.presence.get('show');
     if (api.settings.get('hide_offline_users') && chat_status === 'offline') {
         // If pending or requesting, show
         if ((contact.get('ask') === 'subscribe') ||
                 (contact.get('subscription') === 'from') ||
                 (contact.get('requesting') === true)) {
-            return !isContactFiltered(contact);
+            return !isContactFiltered(contact, groupname);
         }
         return false;
     }
-    return !isContactFiltered(contact);
+    return !isContactFiltered(contact, groupname);
 }
 
 export function shouldShowGroup (group) {