Commit 2179255d authored by JC Brand's avatar JC Brand

Add button for resyncing roster contacts

parent 5e7d5d7f
...@@ -751,6 +751,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -751,6 +751,7 @@ converse.plugins.add('converse-rosterview', {
events: { events: {
'click a.controlbox-heading__btn.add-contact': 'showAddContactModal', 'click a.controlbox-heading__btn.add-contact': 'showAddContactModal',
'click a.controlbox-heading__btn.sync-contacts': 'syncContacts'
}, },
initialize () { initialize () {
...@@ -787,7 +788,8 @@ converse.plugins.add('converse-rosterview', { ...@@ -787,7 +788,8 @@ converse.plugins.add('converse-rosterview', {
this.el.innerHTML = tpl_roster({ this.el.innerHTML = tpl_roster({
'allow_contact_requests': _converse.allow_contact_requests, 'allow_contact_requests': _converse.allow_contact_requests,
'heading_contacts': __('Contacts'), 'heading_contacts': __('Contacts'),
'title_add_contact': __('Add a contact') 'title_add_contact': __('Add a contact'),
'title_sync_contacts': __('Re-sync your contacts')
}); });
const form = this.el.querySelector('.roster-filter-form'); const form = this.el.querySelector('.roster-filter-form');
this.el.replaceChild(this.filter_view.render().el, form); this.el.replaceChild(this.filter_view.render().el, form);
...@@ -861,6 +863,15 @@ converse.plugins.add('converse-rosterview', { ...@@ -861,6 +863,15 @@ converse.plugins.add('converse-rosterview', {
} }
}, },
async syncContacts (ev) {
ev.preventDefault();
u.addClass('fa-spin', ev.target);
_converse.roster.data.save('version', null);
await _converse.roster.fetchFromServer();
_converse.xmppstatus.sendPresence();
u.removeClass('fa-spin', ev.target);
},
reset () { reset () {
_converse.roster.reset(); _converse.roster.reset();
this.removeAll(); this.removeAll();
......
...@@ -401,8 +401,12 @@ converse.plugins.add('converse-roster', { ...@@ -401,8 +401,12 @@ converse.plugins.add('converse-roster', {
let collection; let collection;
try { try {
collection = await new Promise((resolve, reject) => { collection = await new Promise((resolve, reject) => {
const config = {'add': true, 'silent': true, 'success': resolve, 'error': reject}; this.fetch({
this.fetch(config); 'add': true,
'silent': true,
'success': resolve,
'error': reject
});
}); });
} catch (e) { } catch (e) {
return _converse.log(e, Strophe.LogLevel.ERROR); return _converse.log(e, Strophe.LogLevel.ERROR);
...@@ -562,7 +566,7 @@ converse.plugins.add('converse-roster', { ...@@ -562,7 +566,7 @@ converse.plugins.add('converse-roster', {
}, },
rosterVersioningSupported () { rosterVersioningSupported () {
return _converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver') && this.data.get('version'); return !!(_converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver') && this.data.get('version'));
}, },
async fetchFromServer () { async fetchFromServer () {
......
<div class="d-flex controlbox-padded"> <div class="d-flex controlbox-padded">
<span class="w-100 controlbox-heading">{{{o.heading_contacts}}}</span> <span class="w-100 controlbox-heading">{{{o.heading_contacts}}}</span>
<a class="controlbox-heading__btn sync-contacts fa fa-sync" title="{{{o.title_sync_contacts}}}"></a>
{[ if (o.allow_contact_requests) { ]} {[ if (o.allow_contact_requests) { ]}
<a class="controlbox-heading__btn add-contact fa fa-user-plus" <a class="controlbox-heading__btn add-contact fa fa-user-plus"
title="{{{o.title_add_contact}}}" title="{{{o.title_add_contact}}}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment