Jelajahi Sumber

Fix closing MUC from rooms list

View isn't defined if chat is in background
JC Brand 4 tahun lalu
induk
melakukan
a5d428c42d
2 mengubah file dengan 4 tambahan dan 5 penghapusan
  1. 0 1
      dev.html
  2. 4 4
      src/plugins/roomslist/view.js

+ 0 - 1
dev.html

@@ -29,7 +29,6 @@
     converse.initialize({
     converse.initialize({
         auto_away: 300,
         auto_away: 300,
         enable_smacks: true,
         enable_smacks: true,
-        i18n: 'af',
         loglevel: 'debug',
         loglevel: 'debug',
         message_archiving: 'always',
         message_archiving: 'always',
         muc_respect_autojoin: true,
         muc_respect_autojoin: true,

+ 4 - 4
src/plugins/roomslist/view.js

@@ -92,13 +92,13 @@ export class RoomsList extends ElementView {
         api.chatviews.get(jid).maybeFocus();
         api.chatviews.get(jid).maybeFocus();
     }
     }
 
 
-    closeRoom (ev) { // eslint-disable-line class-methods-use-this
+    async closeRoom (ev) { // eslint-disable-line class-methods-use-this
         ev.preventDefault();
         ev.preventDefault();
         const name = ev.target.getAttribute('data-room-name');
         const name = ev.target.getAttribute('data-room-name');
-        const jid = ev.target.getAttribute('data-room-jid');
         if (confirm(__("Are you sure you want to leave the groupchat %1$s?", name))) {
         if (confirm(__("Are you sure you want to leave the groupchat %1$s?", name))) {
-            // TODO: replace with API call
-            _converse.chatboxviews.get(jid).close();
+            const jid = ev.target.getAttribute('data-room-jid');
+            const room = await api.rooms.get(jid);
+            room.close();
         }
         }
     }
     }