2018-06-27 20:53:49 +00:00
|
|
|
/* global Whisper: false */
|
|
|
|
/* global textsecure: false */
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
2018-04-27 21:25:04 +00:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
2018-06-27 20:53:49 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
window.Whisper = window.Whisper || {};
|
2015-09-03 20:33:17 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
Whisper.ContactListView = Whisper.ListView.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
itemView: Whisper.View.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
className: 'contact',
|
|
|
|
templateName: 'contact',
|
2018-06-27 20:53:49 +00:00
|
|
|
initialize(options) {
|
2018-04-27 21:25:04 +00:00
|
|
|
this.ourNumber = textsecure.storage.user.getNumber();
|
|
|
|
this.listenBack = options.listenBack;
|
2019-07-25 16:24:03 +00:00
|
|
|
this.loading = false;
|
2017-06-10 19:18:24 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
this.listenTo(this.model, 'change', this.render);
|
|
|
|
},
|
2018-06-27 20:53:49 +00:00
|
|
|
render() {
|
|
|
|
if (this.contactView) {
|
|
|
|
this.contactView.remove();
|
|
|
|
this.contactView = null;
|
2018-04-27 21:25:04 +00:00
|
|
|
}
|
2017-06-10 19:18:24 +00:00
|
|
|
|
2018-06-27 20:53:49 +00:00
|
|
|
const isMe = this.ourNumber === this.model.id;
|
|
|
|
|
|
|
|
this.contactView = new Whisper.ReactWrapperView({
|
|
|
|
className: 'contact-wrapper',
|
|
|
|
Component: window.Signal.Components.ContactListItem,
|
|
|
|
props: {
|
|
|
|
isMe,
|
2018-09-27 00:23:17 +00:00
|
|
|
color: this.model.getColor(),
|
|
|
|
avatarPath: this.model.getAvatarPath(),
|
2018-06-27 20:53:49 +00:00
|
|
|
phoneNumber: this.model.getNumber(),
|
|
|
|
name: this.model.getName(),
|
|
|
|
profileName: this.model.getProfileName(),
|
|
|
|
verified: this.model.isVerified(),
|
|
|
|
onClick: this.showIdentity.bind(this),
|
2019-07-25 16:24:03 +00:00
|
|
|
disabled: this.loading,
|
2018-06-27 20:53:49 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
this.$el.append(this.contactView.el);
|
|
|
|
return this;
|
2018-04-27 21:25:04 +00:00
|
|
|
},
|
2018-06-27 20:53:49 +00:00
|
|
|
showIdentity() {
|
2019-07-25 16:24:03 +00:00
|
|
|
if (this.model.id === this.ourNumber || this.loading) {
|
2018-04-27 21:25:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-07-25 16:24:03 +00:00
|
|
|
|
|
|
|
this.loading = true;
|
|
|
|
this.render();
|
|
|
|
|
2018-06-27 20:53:49 +00:00
|
|
|
const view = new Whisper.KeyVerificationPanelView({
|
2018-04-27 21:25:04 +00:00
|
|
|
model: this.model,
|
2019-07-25 16:24:03 +00:00
|
|
|
onLoad: () => {
|
|
|
|
this.loading = false;
|
|
|
|
this.listenBack(view);
|
|
|
|
this.render();
|
|
|
|
},
|
2018-04-27 21:25:04 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
2015-09-03 20:33:17 +00:00
|
|
|
})();
|