librelist archives

« back to archive

Fetch Chat Room Configurations based on JID

Fetch Chat Room Configurations based on JID

From:
Gauri Padbidri
Date:
2015-03-23 @ 13:58
Hi JC,

 

In Context to Issue # 346
<https://github.com/jcbrand/converse.js/issues/346> , I already added the
following code to my "this.ChatBoxView" class as follows : 

 

       renderConfigurationFormCustom: function (stanza) {

                var $stanza = $(stanza),

                    $fields =
$stanza.find('field[var="muc#roomconfig_roomname"]');                 

                    

                _.each($fields, function (field) {

                    var a = utils.xForm2webForm($(field), $stanza);

                     console.log(a);

                     console.log(field);

                });                

            },

            show: function (callback) {

                

               // Added by Gauri

              converse.connection.sendIQ(

                        $iq({

                            to: this.model.get('jid'),

                            type: "get"

                        }).c("query", {xmlns: Strophe.NS.MUC_OWNER}).tree(),

                        this.renderConfigurationFormCustom.bind(this)

                );

                if(chatRoomTitle.length > 0){

                   var roomName =
chatRoomTitle.attr('data-room-name').substring(0,
chatRoomTitle.attr('data-room-name').indexOf('('));

                   this.$el.find('.chat-title').attr('title',roomName);

                   this.$el.find('.chat-title').html(roomName);

                }

                this.$el.find('.chat-smiley-toolbar .toggle-otr').remove();

                if (this.$el.is(':visible') && this.$el.css('opacity') ==
"1") {

                    return this.focus();

                }

                this.$el.fadeIn(callback);

                if (converse.connection.connected) {

                    // Without a connection, we haven't yet initialized

                    // localstorage

                    this.model.save();

                    this.initDragResize();

                }

 

                if(this.$el.find('.chat-content').length > 0){

 
this.$el.find('.chat-content').scrollTop(this.$el.find('.chat-content').heig
ht());                      

                }

 

                return this;

            },

 

However SHOW() gets invoked, but the callback named
"renderConfigurationFormCustom" does NOT get invoked in the following
scenario : 

1.       Login as User 1

2.       Login as User 2

3.       Let User 1, send invite to User 2

4.       Before the ChatRoom is displayed to User 2, the show() method gets
invoked.

5.       However, the "renderConfigurationFormCustom" API is not getting
invoked..Can you help me on this one ?

Result : Chat Room should have TITLE set as Room Name and not as JID.

 

Best Regards,

Gauri Padbidri

Re: [conversejs] Fetch Chat Room Configurations based on JID

From:
Jc Brand
Date:
2015-03-25 @ 20:45
Hi Gauri

You'll have to debug this. Set debug=true when calling converse.initialize and
check in the browser console whether there are any errors.

Put some breakpoints in the code and step through it. I can't say what the
issue is simply by looking at what you posted here.

JC


On Mon, Mar 23, 2015 at 07:28:28PM +0530, Gauri Padbidri wrote:
>    Hi JC,
> 
>    In Context to [1]Issue # 346, I already added the following code to my
>    “this.ChatBoxView” class as follows :
> 
>           renderConfigurationFormCustom: function (stanza) {
> 
>                    var $stanza = $(stanza),
> 
>                        $fields =
>    $stanza.find('field[var="muc#roomconfig_roomname"]');                
> 
>                        
> 
>                    _.each($fields, function (field) {
> 
>          &nb sp;             var a = utils.xForm2webForm($(field), $stanza);
> 
>                         console.log(a);
> 
>                         console.log(field);
> 
>                    });               
> 
>                },
> 
>                show: function (callback) {
> 
>                   
> 
>                   // Added by Gauri
> 
>                   converse.connection.sendIQ(
> 
>                            $iq({
> 
>                                to: this.model.get('jid'),
> 
>                                type: "get"
> 
>                            }).c("query", {xmlns:
>    Strophe.NS.MUC_OWNER}).tree(),
> 
>                            this.renderConfigurationFormCustom.bind(this)
> 
>                    );
> 
>                 ;    if(chatRoomTitle.length > 0){
> 
>                       var roomName =
>    chatRoomTitle.attr('data-room-name').substring(0,
>    chatRoomTitle.attr('data-room-name').indexOf('('));
> 
>                       this.$el.find('.chat-title').attr('title',roomName);
> 
>                       this.$el.find('.chat-title').html(roomName);
> 
>                    }
> 
>                    this.$el.find('.chat-smiley-toolbar
>    .toggle-otr').remove();
> 
>                    if (this.$el.is(':visible') && this.$el.css('opacity') ==
>    "1") {
> 
>                        return this.focus();
> 
>                    }
> 
>                    this.$el.fadeIn(callback);
> 
>                    if (converse.connection.connected) {
> 
>                        // Without a connection, we haven't yet initialized
> 
>                        // localstorage
> 
>                        this.model.save();
> 
>                        this.initDragResize();
> 
>                    }
> 
>     
> 
>                    if(this.$el.find('.chat-content').length > 0){
> 
>                               
>    
this.$el.find('.chat-content').scrollTop(this.$el.find('.chat-content').height());                     
> 
>                    }
> 
>     
> 
>                    return this;
> 
>                },
> 
>     
> 
>    However SHOW() gets invoked, but the callback named
>    “renderConfigurationFormCustom” does NOT get invoked in the following
>    scenario :
> 
>    1.       Login as User 1
> 
>    2.       Login as User 2
> 
>    3.       Let User 1, send invite to User 2
> 
>    4.     &nbs p; Before the ChatRoom is displayed to User 2, the show()
>    method gets invoked.
> 
>    5.       However, the “renderConfigurationFormCustom” API is not getting
>    invoked..Can you help me on this one ?
> 
>    Result : Chat Room should have TITLE set as Room Name and not as JID.
> 
>     
> 
>    Best Regards,
> 
>    Gauri Padbidri
> 
> References
> 
>    Visible links
>    1. https://github.com/jcbrand/converse.js/issues/346