Ver código fonte

fix issues after testing on https://conversejs.github.io/community-plugins/

Dele Olajide 4 anos atrás
pai
commit
bfe7833b26
2 arquivos alterados com 15 adições e 11 exclusões
  1. 14 10
      packages/jitsimeet/jitsimeet.js
  2. 1 1
      packages/vmsg/vmsg.js

+ 14 - 10
packages/jitsimeet/jitsimeet.js

@@ -138,20 +138,24 @@
             _converse.api.listen.on('afterMessageBodyTransformed', function(model, text)
             {
                 const body = model.get("body");
-                const pos = body.indexOf("https://");
 
-                if (pos > -1 && body.indexOf(_converse.api.settings.get("jitsimeet_url")) > -1)
+                if (body)
                 {
-                    console.debug("afterMessageBodyTransformed", body, text);
+                    const pos = body.indexOf("https://");
 
-                    const url = body.substring(pos);
-                    const link_jid = Strophe.getBareJidFromJid(model.get("from") || model.get("jid"));
-                    const link_room = url.substring(url.lastIndexOf("/") + 1);
-                    const link_label = jitsimeet_invitation;
-                    const link_id = link_room + "-" + Math.random().toString(36).substr(2,9);
+                    if (pos > -1 && body.indexOf(_converse.api.settings.get("jitsimeet_url")) > -1)
+                    {
+                        console.debug("afterMessageBodyTransformed", body, text);
+
+                        const url = body.substring(pos);
+                        const link_jid = Strophe.getBareJidFromJid(model.get("from") || model.get("jid"));
+                        const link_room = url.substring(url.lastIndexOf("/") + 1);
+                        const link_label = jitsimeet_invitation;
+                        const link_id = link_room + "-" + Math.random().toString(36).substr(2,9);
 
-                    text.references = [];
-                    text.addTemplateResult(0, body.length, html`<a @click=${clickVideo} data-room="${link_room}" data-url="${url}" data-jid="${link_jid}" id="${link_id}" href="#">${link_label} ${link_room}</a>`);
+                        text.references = [];
+                        text.addTemplateResult(0, body.length, html`<a @click=${clickVideo} data-room="${link_room}" data-url="${url}" data-jid="${link_jid}" id="${link_id}" href="#">${link_label} ${link_room}</a>`);
+                    }
                 }
             });
 

+ 1 - 1
packages/vmsg/vmsg.js

@@ -78,7 +78,7 @@
         ev.stopPropagation();
         ev.preventDefault();
 
-        if (!vmsgDialog) vmsgDialog = new VmsgDialog({ 'model': new Model({view: this.chatview}) });
+        vmsgDialog = new VmsgDialog({ 'model': new Model({view: this.chatview}) });
         vmsgDialog.show(ev);
     }
 }));