JC Brand 3 vuotta sitten
vanhempi
commit
b248803a4b
3 muutettua tiedostoa jossa 14 lisäystä ja 7 poistoa
  1. 1 0
      CHANGES.md
  2. 3 1
      src/plugins/dragresize/index.js
  3. 10 6
      src/plugins/singleton/index.js

+ 1 - 0
CHANGES.md

@@ -16,6 +16,7 @@
 - #2788: `TypeError` when trying to use `@converse/headless`
 - #2789: Implement new hook `parseMessageForCommands` for plugins to add custom commands
 - #2814: Links are mangled on open/copy
+- #2822: Singleton doesn't work in overlayed view mode
 
 
 ## 9.0.0 (2021-11-26)

+ 3 - 1
src/plugins/dragresize/index.js

@@ -56,7 +56,9 @@ converse.plugins.add('converse-dragresize', {
 
         Object.assign(_converse.ChatBoxView.prototype, DragResizableMixin);
         Object.assign(_converse.ChatRoomView.prototype, DragResizableMixin);
-        Object.assign(_converse.ControlBoxView.prototype, DragResizableMixin);
+        if (_converse.ControlBoxView) {
+            Object.assign(_converse.ControlBoxView.prototype, DragResizableMixin);
+        }
 
         /************************ BEGIN Event Handlers ************************/
         function registerGlobalEventHandlers () {

+ 10 - 6
src/plugins/singleton/index.js

@@ -15,20 +15,24 @@ converse.plugins.add('converse-singleton', {
     },
 
     initialize () {
-        /* The initialize function gets called as soon as the plugin is
-         * loaded by converse.js's plugin machinery.
-         */
         api.settings.extend({
             'allow_logout': false,          // No point in logging out when we have auto_login as true.
             'allow_muc_invitations': false, // Doesn't make sense to allow because only
                                             // roster contacts can be invited
             'hide_muc_server': true
         });
-        if (!Array.isArray(api.settings.get('auto_join_rooms')) &&
-                !Array.isArray(api.settings.get('auto_join_private_chats'))) {
+
+        const auto_join_rooms = api.settings.get('auto_join_rooms');
+        const auto_join_private_chats = api.settings.get('auto_join_private_chats');
+
+        if (!Array.isArray(auto_join_rooms) && !Array.isArray(auto_join_private_chats)) {
             throw new Error("converse-singleton: auto_join_rooms must be an Array");
         }
-        if (api.settings.get('auto_join_rooms').length > 1 || api.settings.get('auto_join_private_chats').length > 1) {
+        if (auto_join_rooms.length === 0 && auto_join_private_chats.length === 0) {
+            throw new Error("If you set singleton set to true, you need "+
+                "to specify auto_join_rooms or auto_join_private_chats");
+        }
+        if (auto_join_rooms.length > 0 && auto_join_private_chats.length > 0) {
             throw new Error("It doesn't make sense to have singleton set to true and " +
                 "auto_join_rooms or auto_join_private_chats set to more then one, " +
                 "since only one chat room may be open at any time.");