librelist archives

« back to archive

Rename contact display name

Rename contact display name

From:
ajinkya chhatre
Date:
2015-08-09 @ 22:15
Greetings JC,

I am trying to implement a rename display name feature for the added
contacts.

Questions:
1.) Is it possible to do?
2.) If yes, then the following doesn't update the roster:

if (connectionItem && connectionItem.subscription === "both")
{
     converse.connection.roster.update(jid, $displayName.val(), [], null);
}

The display name changes when I reload the page.
I have tried resetting, updating the rosterview by adding a callback
function instead of null, but it seems I am missing out on something.

Your reply would really help me a lot.

Best regards,
Ajinkya D. Chhatre | UI/UX Developer,
*Cell*: 091-8055744567, 091-8087791959
*LinkedIn*: http://www.linkedin.com/in/ajinkyachhatre
<http://www.linkedin.com/in/ajinkyachhatre>

Re: Rename contact display name

From:
ajinkya chhatre
Date:
2015-08-09 @ 22:19
Greetings JC,

Here's the actual snippet:

                    var $email = $(ev.target).find('#email'),
                    $displayName = $(ev.target).find('#display'),
                    jid = $email.val();

                    if (!jid) {
                        // this is not a valid JID
                        $email.addClass('error');
                        return;
                    }

                   this.closeAddContactForm();

                   var connectionItem =
converse.connection.roster.findItem(jid);

                   if (connectionItem && connectionItem.subscription ===
"both")  {
                       converse.connection.roster.update(jid,
$displayName.val(), [], null);
                   }

Best regards,
Ajinkya D. Chhatre | UI/UX Developer,
*Cell*: 091-8055744567, 091-8087791959
*LinkedIn*: http://www.linkedin.com/in/ajinkyachhatre

On Mon, Aug 10, 2015 at 3:45 AM, ajinkya chhatre <ajinkyachhatre@gmail.com>
wrote:

> Greetings JC,
>
> I am trying to implement a rename display name feature for the added
> contacts.
>
> Questions:
> 1.) Is it possible to do?
> 2.) If yes, then the following doesn't update the roster:
>
> if (connectionItem && connectionItem.subscription === "both")
> {
>      converse.connection.roster.update(jid, $displayName.val(), [], null);
> }
>
> The display name changes when I reload the page.
> I have tried resetting, updating the rosterview by adding a callback
> function instead of null, but it seems I am missing out on something.
>
> Your reply would really help me a lot.
>
> Best regards,
> Ajinkya D. Chhatre | UI/UX Developer,
> *Cell*: 091-8055744567, 091-8087791959
> *LinkedIn*: http://www.linkedin.com/in/ajinkyachhatre
> <http://www.linkedin.com/in/ajinkyachhatre>
>

Re: Rename contact display name

From:
ajinkya chhatre
Date:
2015-08-10 @ 15:44
Greetings JC,

Here's what I did to get rename thing working:

var connectionItem = converse.connection.roster.findItem(jid);
                    if (connectionItem && connectionItem.subscription ===
"both") {
                        converse.connection.roster.update(jid,
$displayName.val(), [], null);

                        var contact = converse.roster.get(jid);
                        if (contact) {
                            contact.attributes.fullname =
$displayName.val();
                            converse.getVCard(contact.get('jid'));
                        }
                    }

Is changing the fullname attribute and updating vcard the right way to
achieve this?

On Mon, Aug 10, 2015 at 3:49 AM, ajinkya chhatre <ajinkyachhatre@gmail.com>
wrote:

> Greetings JC,
>
> Here's the actual snippet:
>
>                     var $email = $(ev.target).find('#email'),
>                     $displayName = $(ev.target).find('#display'),
>                     jid = $email.val();
>
>                     if (!jid) {
>                         // this is not a valid JID
>                         $email.addClass('error');
>                         return;
>                     }
>
>                    this.closeAddContactForm();
>
>                    var connectionItem =
> converse.connection.roster.findItem(jid);
>
>                    if (connectionItem && connectionItem.subscription ===
> "both")  {
>                        converse.connection.roster.update(jid,
> $displayName.val(), [], null);
>                    }
>
> Best regards,
> Ajinkya D. Chhatre | UI/UX Developer,
> *Cell*: 091-8055744567, 091-8087791959
> *LinkedIn*: http://www.linkedin.com/in/ajinkyachhatre
>
> On Mon, Aug 10, 2015 at 3:45 AM, ajinkya chhatre <ajinkyachhatre@gmail.com
> > wrote:
>
>> Greetings JC,
>>
>> I am trying to implement a rename display name feature for the added
>> contacts.
>>
>> Questions:
>> 1.) Is it possible to do?
>> 2.) If yes, then the following doesn't update the roster:
>>
>> if (connectionItem && connectionItem.subscription === "both")
>> {
>>      converse.connection.roster.update(jid, $displayName.val(), [], null);
>> }
>>
>> The display name changes when I reload the page.
>> I have tried resetting, updating the rosterview by adding a callback
>> function instead of null, but it seems I am missing out on something.
>>
>> Your reply would really help me a lot.
>>
>> Best regards,
>> Ajinkya D. Chhatre | UI/UX Developer,
>> *Cell*: 091-8055744567, 091-8087791959
>> *LinkedIn*: http://www.linkedin.com/in/ajinkyachhatre
>> <http://www.linkedin.com/in/ajinkyachhatre>
>>
>
>


-- 
Best regards,
Ajinkya D. Chhatre | UI/UX Developer,
*Cell*: 091-8055744567, 091-8087791959
*LinkedIn*: http://www.linkedin.com/in/ajinkyachhatre
<http://www.linkedin.com/in/ajinkyachhatre>

Re: [conversejs] Re: Rename contact display name

From:
Jc Brand
Date:
2015-08-10 @ 16:32
On Mon, Aug 10, 2015 at 09:14:32PM +0530, ajinkya chhatre wrote:
>    Greetings JC,
> 
>    Here's what I did to get rename thing working:
> 
>    var connectionItem = converse.connection.roster.findItem(jid);
>                        if (connectionItem && connectionItem.subscription ===
>    "both") {
>                            converse.connection.roster.update(jid,
>    $displayName.val(), [], null);
> 
>                            var contact = converse.roster.get(jid);
>                            if (contact) {
>                                contact.attributes.fullname =
>    $displayName.val();
>                                converse.getVCard(contact.get('jid'));
>                            }
>                        }
> 
>    Is changing the fullname attribute and updating vcard the right way to
>    achieve this?

Hi Ajinkya

If you want to change the display name of your roster contacts, then changing
the vcard's fullname property is not the right approach, because then you are
changing that user's name globally, instead of just for yourself.

Instead, your roster contacts have a "name" property in which you can set a
nickname.

See here:
https://xmpp.org/rfcs/rfc3921.html#rfc.section.7.5

So, when you want to set your own nickname for a user, you should set it there.

This would be a nice feature to have and a pull request would be appreciated.

JC