signal-desktop/js/views/contact_list_view.js

61 lines
1.6 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: false */
/* global textsecure: false */
// eslint-disable-next-line func-names
2018-04-27 21:25:04 +00:00
(function() {
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',
templateName: 'contact',
initialize(options) {
2018-04-27 21:25:04 +00:00
this.ourNumber = textsecure.storage.user.getNumber();
this.listenBack = options.listenBack;
this.loading = false;
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
}
this.contactView = new Whisper.ReactWrapperView({
className: 'contact-wrapper',
Component: window.Signal.Components.ContactListItem,
props: {
2020-09-09 02:25:05 +00:00
...this.model.format(),
onClick: this.showIdentity.bind(this),
},
});
this.$el.append(this.contactView.el);
return this;
2018-04-27 21:25:04 +00:00
},
showIdentity() {
if (this.model.isMe() || this.loading) {
2018-04-27 21:25:04 +00:00
return;
}
this.loading = true;
this.render();
this.panelView = new Whisper.KeyVerificationPanelView({
2018-04-27 21:25:04 +00:00
model: this.model,
onLoad: view => {
this.loading = false;
this.listenBack(view);
this.render();
},
2018-04-27 21:25:04 +00:00
});
},
}),
});
})();