Explorar o código

fix: TypeError: Cannot read properties of undefined (reading 'toLowerCase')

JC Brand hai 1 mes
pai
achega
ab7d1643e2

+ 5 - 5
src/headless/plugins/bookmarks/collection.js

@@ -22,6 +22,11 @@ class Bookmarks extends Collection {
         return 'jid';
     }
 
+    constructor() {
+        super([], { comparator: (/** @type {Bookmark} */ b) => b.getDisplayName().toLowerCase() });
+        this.model = Bookmark;
+    }
+
     async initialize() {
         this.on('add', (bm) =>
             this.openBookmarkedRoom(bm)
@@ -66,11 +71,6 @@ class Bookmarks extends Collection {
         }
     }
 
-    constructor() {
-        super([], { comparator: (/** @type {Bookmark} */ b) => b.get('name').toLowerCase() });
-        this.model = Bookmark;
-    }
-
     /**
      * @param {Bookmark} bookmark
      */

+ 1 - 1
src/headless/plugins/bookmarks/model.js

@@ -9,7 +9,7 @@ class Bookmark extends Model {
     }
 
     getDisplayName () {
-        return Strophe.xmlunescape(this.get('name'));
+        return Strophe.xmlunescape(this.get('name')) || this.get('jid');
     }
 }
 

+ 1 - 1
src/headless/types/plugins/bookmarks/collection.d.ts

@@ -4,9 +4,9 @@ declare class Bookmarks extends Collection {
     static checkBookmarksSupport(): Promise<any>;
     constructor();
     get idAttribute(): string;
+    model: typeof Bookmark;
     initialize(): Promise<void>;
     fetched_flag: string;
-    model: typeof Bookmark;
     /**
      * @param {Bookmark} bookmark
      */