|
@@ -1,19 +1,26 @@
|
|
|
-import { api, converse, log } from "@converse/headless";
|
|
|
+import { api } from "@converse/headless";
|
|
|
import { blockContact, removeContact, unblockContact } from 'plugins/rosterview/utils.js';
|
|
|
import BaseModal from "plugins/modal/modal.js";
|
|
|
import { __ } from 'i18n';
|
|
|
import { tplUserDetailsModal } from "./templates/user-details.js";
|
|
|
|
|
|
-const u = converse.env.utils;
|
|
|
-
|
|
|
|
|
|
export default class UserDetailsModal extends BaseModal {
|
|
|
|
|
|
initialize () {
|
|
|
super.initialize();
|
|
|
- this.model.rosterContactAdded.then(() => this.registerContactEventHandlers());
|
|
|
+ this.model.rosterContactAdded.then(() => {
|
|
|
+ this.registerContactEventHandlers();
|
|
|
+ api.vcard.update(this.model.contact.vcard, true);
|
|
|
+ });
|
|
|
this.listenTo(this.model, 'change', this.render);
|
|
|
- this.registerContactEventHandlers();
|
|
|
+
|
|
|
+ if (this.model.contact !== undefined) {
|
|
|
+ this.registerContactEventHandlers();
|
|
|
+ // Refresh the vcard
|
|
|
+ api.vcard.update(this.model.contact.vcard, true);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Triggered once the UserDetailsModal has been initialized
|
|
|
* @event _converse#userDetailsModalInitialized
|
|
@@ -32,27 +39,15 @@ export default class UserDetailsModal extends BaseModal {
|
|
|
}
|
|
|
|
|
|
registerContactEventHandlers () {
|
|
|
- if (this.model.contact !== undefined) {
|
|
|
- this.listenTo(this.model.contact, 'change', this.render);
|
|
|
- this.listenTo(this.model.contact.vcard, 'change', this.render);
|
|
|
- this.model.contact.on('destroy', () => {
|
|
|
- delete this.model.contact;
|
|
|
- this.render();
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ this.listenTo(this.model.contact, 'change', this.render);
|
|
|
+ this.listenTo(this.model.contact.vcard, 'change', this.render);
|
|
|
+ this.model.contact.on('destroy', () => {
|
|
|
+ delete this.model.contact;
|
|
|
+ this.render();
|
|
|
+ });
|
|
|
|
|
|
- async refreshContact (ev) {
|
|
|
- if (ev && ev.preventDefault) { ev.preventDefault(); }
|
|
|
- const refresh_icon = this.querySelector('.fa-refresh');
|
|
|
- u.addClass('fa-spin', refresh_icon);
|
|
|
- try {
|
|
|
- await api.vcard.update(this.model.contact.vcard, true);
|
|
|
- } catch (e) {
|
|
|
- log.fatal(e);
|
|
|
- this.alert(__('Sorry, something went wrong while trying to refresh'), 'danger');
|
|
|
- }
|
|
|
- u.removeClass('fa-spin', refresh_icon);
|
|
|
+ // Refresh the vcard
|
|
|
+ api.vcard.update(this.model.contact.vcard, true);
|
|
|
}
|
|
|
|
|
|
/**
|