signal-desktop/js/views/contact_list_view.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2015-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* global Whisper, textsecure, $ */
// eslint-disable-next-line func-names
(function () {
2018-04-27 21:25:04 +00:00
window.Whisper = window.Whisper || {};
2018-04-27 21:25:04 +00:00
Whisper.ContactListView = Whisper.ListView.extend({
tagName: 'div',
itemView: Whisper.View.extend({
tagName: 'div',
className: 'contact',
template: () => $('#contact').html(),
initialize(options) {
2018-04-27 21:25:04 +00:00
this.ourNumber = textsecure.storage.user.getNumber();
this.listenBack = options.listenBack;
this.loading = false;
this.conversation = options.conversation;
2018-04-27 21:25:04 +00:00
this.listenTo(this.model, 'change', this.render);
},
render() {
if (this.contactView) {
this.contactView.remove();
this.contactView = null;
2018-04-27 21:25:04 +00:00
}
const formattedContact = this.model.format();
this.contactView = new Whisper.ReactWrapperView({
className: 'contact-wrapper',
Component: window.Signal.Components.ContactListItem,
props: {
...formattedContact,
onClick: () =>
this.conversation.trigger(
'show-contact-modal',
formattedContact.id
),
},
});
this.$el.append(this.contactView.el);
return this;
2018-04-27 21:25:04 +00:00
},
}),
});
})();