Browse Source

Fixes #2348

Don't automatically hide the first MUC opened in uni-view
JC Brand 4 năm trước cách đây
mục cha
commit
3c99f1f840

+ 1 - 0
CHANGES.md

@@ -4,6 +4,7 @@
 
 
 - #1083: Add support for XEP-0393 Message Styling
 - #1083: Add support for XEP-0393 Message Styling
 - #2275: Allow punctuation to immediately precede a mention
 - #2275: Allow punctuation to immediately precede a mention
+- #2348: `auto_join_room` not showing the room in `fullscreen` `view_mode`.
 - #2400: Fixes infinite loop bug when appending .png to allowed image urls
 - #2400: Fixes infinite loop bug when appending .png to allowed image urls
 - #2409: Integrate App Badging API for unread messages
 - #2409: Integrate App Badging API for unread messages
 - Add support for XEP-0437 Room Activity Indicators see [muc-subscribe-to-rai](https://conversejs.org/docs/html/configuration.html#muc-subscribe-to-rai)
 - Add support for XEP-0437 Room Activity Indicators see [muc-subscribe-to-rai](https://conversejs.org/docs/html/configuration.html#muc-subscribe-to-rai)

+ 12 - 0
spec/muc.js

@@ -104,6 +104,18 @@ describe("Groupchats", function () {
 
 
     describe("A Groupchat", function () {
     describe("A Groupchat", function () {
 
 
+        it("will be visible when opened as the first chat in fullscreen-view",
+                mock.initConverse(['discoInitialized'],
+                    { 'view_mode': 'fullscreen', 'auto_join_rooms': ['orchard@chat.shakespeare.lit']},
+                    async function (done, _converse) {
+
+            const { api } = _converse;
+            await api.waitUntil('roomsAutoJoined');
+            const room = await api.rooms.get('orchard@chat.shakespeare.lit');
+            expect(room.get('hidden')).toBe(false);
+            return done();
+        }));
+
         it("Can be configured to show cached messages before being joined",
         it("Can be configured to show cached messages before being joined",
             mock.initConverse(['discoInitialized'],
             mock.initConverse(['discoInitialized'],
                 {
                 {

+ 10 - 12
src/headless/plugins/chat/model.js

@@ -976,23 +976,21 @@ const ChatBox = ModelWithContact.extend({
     },
     },
 
 
     maybeShow (force) {
     maybeShow (force) {
-        if (force) {
-            if (_converse.isUniView()) {
+        if (_converse.isUniView()) {
+            const filter = c => !c.get('hidden') &&
+                c.get('jid') !== this.get('jid') &&
+                c.get('id') !== 'controlbox';
+            const other_chats = _converse.chatboxes.filter(filter);
+            if (force || other_chats.length === 0) {
                 // We only have one chat visible at any one time.
                 // We only have one chat visible at any one time.
                 // So before opening a chat, we make sure all other chats are hidden.
                 // So before opening a chat, we make sure all other chats are hidden.
-                const filter = c => !c.get('hidden') &&
-                    c.get('jid') !== this.get('jid') &&
-                    c.get('id') !== 'controlbox';
-                _converse.chatboxes.filter(filter).forEach(c => u.safeSave(c, {'hidden': true}));
+                other_chats.forEach(c => u.safeSave(c, {'hidden': true}));
+                u.safeSave(this, {'hidden': false});
             }
             }
-            u.safeSave(this, {'hidden': false});
-        }
-        if (_converse.isUniView()) {
             return;
             return;
-        } else {
-            u.safeSave(this, {'hidden': false});
-            this.trigger('show');
         }
         }
+        u.safeSave(this, {'hidden': false});
+        this.trigger('show');
         return this;
         return this;
     },
     },
 
 

+ 2 - 2
src/headless/plugins/muc/api.js

@@ -105,11 +105,11 @@ export default {
                 throw new TypeError(err_msg);
                 throw new TypeError(err_msg);
             } else if (typeof jids === 'string') {
             } else if (typeof jids === 'string') {
                 const room = await api.rooms.get(jids, attrs, true);
                 const room = await api.rooms.get(jids, attrs, true);
-                room && room.maybeShow(force);
+                !attrs.hidden && room?.maybeShow(force);
                 return room;
                 return room;
             } else {
             } else {
                 const rooms = await Promise.all(jids.map(jid => api.rooms.get(jid, attrs, true)));
                 const rooms = await Promise.all(jids.map(jid => api.rooms.get(jid, attrs, true)));
-                rooms.forEach(r => r.maybeShow(force));
+                rooms.forEach(r => !attrs.hidden && r.maybeShow(force));
                 return rooms;
                 return rooms;
             }
             }
         },
         },