2020-10-30 15:34:04 -05:00
|
|
|
// Copyright 2015-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-02-26 13:06:37 -08:00
|
|
|
/* global Whisper, textsecure, $ */
|
2018-06-27 13:53:49 -07:00
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
2020-11-18 07:15:42 -08:00
|
|
|
(function () {
|
2018-04-27 17:25:04 -04:00
|
|
|
window.Whisper = window.Whisper || {};
|
2015-09-03 13:33:17 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
Whisper.ContactListView = Whisper.ListView.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
itemView: Whisper.View.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
className: 'contact',
|
2021-02-26 13:06:37 -08:00
|
|
|
template: () => $('#contact').html(),
|
2018-06-27 13:53:49 -07:00
|
|
|
initialize(options) {
|
2018-04-27 17:25:04 -04:00
|
|
|
this.ourNumber = textsecure.storage.user.getNumber();
|
|
|
|
this.listenBack = options.listenBack;
|
2019-07-25 12:24:03 -04:00
|
|
|
this.loading = false;
|
2020-11-11 09:36:05 -08:00
|
|
|
this.conversation = options.conversation;
|
2017-06-10 12:18:24 -07:00
|
|
|
|
2018-04-27 17:25:04 -04:00
|
|
|
this.listenTo(this.model, 'change', this.render);
|
|
|
|
},
|
2018-06-27 13:53:49 -07:00
|
|
|
render() {
|
|
|
|
if (this.contactView) {
|
|
|
|
this.contactView.remove();
|
|
|
|
this.contactView = null;
|
2018-04-27 17:25:04 -04:00
|
|
|
}
|
2017-06-10 12:18:24 -07:00
|
|
|
|
2020-11-11 09:36:05 -08:00
|
|
|
const formattedContact = this.model.format();
|
|
|
|
|
2018-06-27 13:53:49 -07:00
|
|
|
this.contactView = new Whisper.ReactWrapperView({
|
|
|
|
className: 'contact-wrapper',
|
|
|
|
Component: window.Signal.Components.ContactListItem,
|
|
|
|
props: {
|
2020-11-11 09:36:05 -08:00
|
|
|
...formattedContact,
|
|
|
|
onClick: () =>
|
|
|
|
this.conversation.trigger(
|
|
|
|
'show-contact-modal',
|
|
|
|
formattedContact.id
|
|
|
|
),
|
2018-06-27 13:53:49 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
this.$el.append(this.contactView.el);
|
|
|
|
return this;
|
2018-04-27 17:25:04 -04:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
2015-09-03 13:33:17 -07:00
|
|
|
})();
|