瀏覽代碼

Use API to get room

JC Brand 4 年之前
父節點
當前提交
b2f09f64c3
共有 2 個文件被更改,包括 8 次插入6 次删除
  1. 7 5
      src/headless/plugins/muc/api.js
  2. 1 1
      src/plugins/muc-views/muc.js

+ 7 - 5
src/headless/plugins/muc/api.js

@@ -118,10 +118,12 @@ export default {
          * Fetches the object representing a MUC chatroom (aka groupchat)
          * Fetches the object representing a MUC chatroom (aka groupchat)
          *
          *
          * @method api.rooms.get
          * @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`)
          *     if not found (default: `false`)
          * @returns { Promise<_converse.ChatRoom> }
          * @returns { Promise<_converse.ChatRoom> }
          * @example
          * @example
@@ -129,7 +131,7 @@ export default {
          *     const create_if_not_found = true;
          *     const create_if_not_found = true;
          *     api.rooms.get(
          *     api.rooms.get(
          *         'group@muc.example.com',
          *         'group@muc.example.com',
-         *         {'nick': 'dread-pirate-roberts'},
+         *         {'nick': 'dread-pirate-roberts', 'password': 'secret'},
          *         create_if_not_found
          *         create_if_not_found
          *     )
          *     )
          * });
          * });

+ 1 - 1
src/plugins/muc-views/muc.js

@@ -19,7 +19,7 @@ export default class MUCView extends BaseChatView {
 
 
     async initialize () {
     async initialize () {
         const jid = this.getAttribute('jid');
         const jid = this.getAttribute('jid');
-        this.model = _converse.chatboxes.get(jid);
+        this.model = await api.rooms.get(jid);
         _converse.chatboxviews.add(jid, this);
         _converse.chatboxviews.add(jid, this);
         this.initDebounced();
         this.initDebounced();