2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2015-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-06-27 20:53:49 +00:00
|
|
|
/* global Whisper: false */
|
|
|
|
/* global textsecure: false */
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
2020-11-18 15:15:42 +00:00
|
|
|
(function () {
|
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;
|
2020-11-11 17:36:05 +00:00
|
|
|
this.conversation = options.conversation;
|
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
|
|
|
|
2020-11-11 17:36:05 +00:00
|
|
|
const formattedContact = this.model.format();
|
|
|
|
|
2018-06-27 20:53:49 +00:00
|
|
|
this.contactView = new Whisper.ReactWrapperView({
|
|
|
|
className: 'contact-wrapper',
|
|
|
|
Component: window.Signal.Components.ContactListItem,
|
|
|
|
props: {
|
2020-11-11 17:36:05 +00:00
|
|
|
...formattedContact,
|
|
|
|
onClick: () =>
|
|
|
|
this.conversation.trigger(
|
|
|
|
'show-contact-modal',
|
|
|
|
formattedContact.id
|
|
|
|
),
|
2018-06-27 20:53:49 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
this.$el.append(this.contactView.el);
|
|
|
|
return this;
|
2018-04-27 21:25:04 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
2015-09-03 20:33:17 +00:00
|
|
|
})();
|