diff --git a/CHANGES.md b/CHANGES.md index 2fab58218..34868b029 100644 --- a/CHANGES.md +++ b/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) diff --git a/src/plugins/dragresize/index.js b/src/plugins/dragresize/index.js index 73a5c851e..01b0638e2 100644 --- a/src/plugins/dragresize/index.js +++ b/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 () { diff --git a/src/plugins/singleton/index.js b/src/plugins/singleton/index.js index 65953c2c6..e9ad1101b 100644 --- a/src/plugins/singleton/index.js +++ b/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.");