From b2f09f64c35f64a417e7a4b06f32eddb4465c5df Mon Sep 17 00:00:00 2001 From: JC Brand Date: Mon, 19 Apr 2021 15:23:58 +0200 Subject: [PATCH] Use API to get room --- src/headless/plugins/muc/api.js | 12 +++++++----- src/plugins/muc-views/muc.js | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/headless/plugins/muc/api.js b/src/headless/plugins/muc/api.js index 7ef5121e4..7ce2b587b 100644 --- a/src/headless/plugins/muc/api.js +++ b/src/headless/plugins/muc/api.js @@ -118,10 +118,12 @@ export default { * Fetches the object representing a MUC chatroom (aka groupchat) * * @method api.rooms.get - * @param {string} [jid] The room JID (if not specified, all rooms will be returned). - * @param {object} [attrs] A map containing any extra room attributes For example, if you want - * to specify a nickname and password, use `{'nick': 'bloodninja', 'password': 'secret'}`. - * @param {boolean} create A boolean indicating whether the room should be created + * @param { String } [jid] The room JID (if not specified, all rooms will be returned). + * @param { Object } [attrs] A map containing any extra room attributes + * to be set if `create` is set to `true` + * @param { String } [attrs.nick] Specify the nickname + * @param { String } [attrs.password ] Specify a password if needed to enter a new room + * @param { Boolean } create A boolean indicating whether the room should be created * if not found (default: `false`) * @returns { Promise<_converse.ChatRoom> } * @example @@ -129,7 +131,7 @@ export default { * const create_if_not_found = true; * api.rooms.get( * 'group@muc.example.com', - * {'nick': 'dread-pirate-roberts'}, + * {'nick': 'dread-pirate-roberts', 'password': 'secret'}, * create_if_not_found * ) * }); diff --git a/src/plugins/muc-views/muc.js b/src/plugins/muc-views/muc.js index 329500988..e619db83b 100644 --- a/src/plugins/muc-views/muc.js +++ b/src/plugins/muc-views/muc.js @@ -19,7 +19,7 @@ export default class MUCView extends BaseChatView { async initialize () { const jid = this.getAttribute('jid'); - this.model = _converse.chatboxes.get(jid); + this.model = await api.rooms.get(jid); _converse.chatboxviews.add(jid, this); this.initDebounced();