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', {
events: {
'click a.controlbox-heading__btn.add-contact': 'showAddContactModal',
'click a.controlbox-heading__btn.sync-contacts': 'syncContacts'
},
initialize () {
......@@ -787,7 +788,8 @@ converse.plugins.add('converse-rosterview', {
this.el.innerHTML = tpl_roster({
'allow_contact_requests': _converse.allow_contact_requests,
'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');
this.el.replaceChild(this.filter_view.render().el, form);
......@@ -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 () {
_converse.roster.reset();
this.removeAll();
......
......@@ -401,8 +401,12 @@ converse.plugins.add('converse-roster', {
let collection;
try {
collection = await new Promise((resolve, reject) => {
const config = {'add': true, 'silent': true, 'success': resolve, 'error': reject};
this.fetch(config);
this.fetch({
'add': true,
'silent': true,
'success': resolve,
'error': reject
});
});
} catch (e) {
return _converse.log(e, Strophe.LogLevel.ERROR);
......@@ -562,7 +566,7 @@ converse.plugins.add('converse-roster', {
},
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 () {
......
<div class="d-flex controlbox-padded">
<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) { ]}
<a class="controlbox-heading__btn add-contact fa fa-user-plus"
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