Show all contacts.

pull/64/head
Mikunj 7 years ago
parent 3eb193cca2
commit d6d71cb51e

@ -60,7 +60,7 @@
<div class='conversations-list'> <div class='conversations-list'>
<h4 class='section-toggle section-toggle-visible'>Conversations</h4> <h4 class='section-toggle section-toggle-visible'>Conversations</h4>
<div class='conversations inbox'></div> <div class='conversations inbox'></div>
<h4 class='section-toggle section-toggle-visible'>Friends</h4> <h4 class='section-toggle section-toggle-visible'>Contacts</h4>
<div class='conversations friends'></div> <div class='conversations friends'></div>
</div> </div>
<div class='conversations search-results hide'> <div class='conversations search-results hide'>
@ -135,13 +135,13 @@
<div class='flex'> <div class='flex'>
<button class='emoji' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></button> <button class='emoji' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></button>
<textarea class='send-message' placeholder='{{ send-message }}' rows='1' dir='auto' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></textarea> <textarea class='send-message' placeholder='{{ send-message }}' rows='1' dir='auto' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></textarea>
<div class='capture-audio' hide> <div class='capture-audio hide'>
<button class='microphone' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></button> <button class='microphone' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></button>
</div> </div>
<div class='android-length-warning'> <div class='android-length-warning'>
{{ android-length-warning }} {{ android-length-warning }}
</div> </div>
<div class='choose-file' hide> <div class='choose-file hide'>
<button class='paperclip thumbnail' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></button> <button class='paperclip thumbnail' {{#disable-inputs}} disabled="disabled" {{/disable-inputs}}></button>
<input type='file' class='file-input'> <input type='file' class='file-input'>
</div> </div>

@ -11,7 +11,7 @@
const conversations = new Whisper.ConversationCollection(); const conversations = new Whisper.ConversationCollection();
const inboxCollection = new (Backbone.Collection.extend({ const inboxCollection = new (Backbone.Collection.extend({
initialize() { initialize() {
this.on('change:timestamp change:name change:number change:profileName', this.sort); this.on('change:timestamp change:name change:number', this.sort);
this.listenTo(conversations, 'add change:active_at', this.addActive); this.listenTo(conversations, 'add change:active_at', this.addActive);
this.listenTo(conversations, 'reset', () => this.reset([])); this.listenTo(conversations, 'reset', () => this.reset([]));
@ -44,6 +44,7 @@
addActive(model) { addActive(model) {
if (model.get('active_at')) { if (model.get('active_at')) {
this.add(model); this.add(model);
model.updateLastMessage();
} else { } else {
this.remove(model); this.remove(model);
} }
@ -77,7 +78,7 @@
window.getInboxCollection = () => inboxCollection; window.getInboxCollection = () => inboxCollection;
const friendCollection = new (Backbone.Collection.extend({ const contactCollection = new (Backbone.Collection.extend({
initialize() { initialize() {
this.on('change:timestamp change:name change:number change:profileName', this.sort); this.on('change:timestamp change:name change:number change:profileName', this.sort);
@ -94,16 +95,16 @@
addActive(model) { addActive(model) {
// We only want models which are not shown in the inbox // We only want models which are not shown in the inbox
// And that we are friends with // And that we are friends with
const inboxHasModel = inboxCollection.contains(model); if (model.isFriend()) {
if (!inboxHasModel) {
this.add(model); this.add(model);
model.updateLastMessage();
} else { } else {
this.remove(model); this.remove(model);
} }
}, },
}))(); }))();
window.getFriendCollection = () => friendCollection; window.getContactCollection = () => contactCollection;
window.ConversationController = { window.ConversationController = {
markAsSelected(toSelect) { markAsSelected(toSelect) {

@ -25,13 +25,17 @@
Backbone.View.prototype.remove.call(this); Backbone.View.prototype.remove.call(this);
}, },
getProps() {
return this.model.getPropsForListItem();
},
render() { render() {
if (this.childView) { if (this.childView) {
this.childView.remove(); this.childView.remove();
this.childView = null; this.childView = null;
} }
const props = this.model.getPropsForListItem(); const props = this.getProps();
this.childView = new Whisper.ReactWrapperView({ this.childView = new Whisper.ReactWrapperView({
className: 'list-item-wrapper', className: 'list-item-wrapper',
Component: Signal.Components.ConversationListItem, Component: Signal.Components.ConversationListItem,
@ -39,7 +43,7 @@
}); });
const update = () => const update = () =>
this.childView.update(this.model.getPropsForListItem()); this.childView.update(this.getProps());
this.listenTo(this.model, 'change', update); this.listenTo(this.model, 'change', update);
@ -48,4 +52,16 @@
return this; return this;
}, },
}); });
// list of conversations, showing user/group and last message sent
Whisper.ConversationContactListItemView = Whisper.ConversationListItemView.extend({
getProps() {
// We don't want to show a timestamp or a message
const props = this.model.getPropsForListItem();
delete props.lastMessage;
delete props.lastUpdated;
return props;
},
});
})(); })();

@ -65,4 +65,8 @@
} }
}, },
}); });
Whisper.ConversationContactListView = Whisper.ListView.extend({
itemView: Whisper.ConversationContactListItemView,
});
})(); })();

@ -86,6 +86,9 @@
this.typeahead.filter(isSearchable) this.typeahead.filter(isSearchable)
); );
// This will allow us to show the last message when searching
this.typeahead_view.collection.forEach(c => c.updateLastMessage());
// Check if the query is in the model list // Check if the query is in the model list
// If it is then hide the new contact view // If it is then hide the new contact view
const modelExists = this.typeahead_view.collection.find(item => item.get('id') === query); const modelExists = this.typeahead_view.collection.find(item => item.get('id') === query);

@ -474,14 +474,17 @@
}, },
toggleMicrophone() { toggleMicrophone() {
if ( // ALWAYS HIDE until we support audio
this.$('.send-message').val().length > 0 || this.$('.capture-audio').hide();
this.fileInput.hasFiles()
) { // if (
this.$('.capture-audio').hide(); // this.$('.send-message').val().length > 0 ||
} else { // this.fileInput.hasFiles()
this.$('.capture-audio').show(); // ) {
} // this.$('.capture-audio').hide();
// } else {
// this.$('.capture-audio').show();
// }
}, },
toggleLengthWarning() { toggleLengthWarning() {
if (this.$('.send-message').val().length > 2000) { if (this.$('.send-message').val().length > 2000) {

@ -1,7 +1,7 @@
/* global ConversationController: false */ /* global ConversationController: false */
/* global extension: false */ /* global extension: false */
/* global getInboxCollection: false */ /* global getInboxCollection: false */
/* global getFriendCollection: false */ /* global getContactCollection: false */
/* global i18n: false */ /* global i18n: false */
/* global Whisper: false */ /* global Whisper: false */
/* global textsecure: false */ /* global textsecure: false */
@ -166,25 +166,25 @@
); );
// Friends // Friends
const friendCollection = getFriendCollection(); const contactCollection = getContactCollection();
this.listenTo(friendCollection, 'select', this.openConversation); this.listenTo(contactCollection, 'select', this.openConversation);
this.friendListView = new Whisper.ConversationListView({ this.contactListView = new Whisper.ConversationContactListView({
el: this.$('.friends'), el: this.$('.friends'),
collection: friendCollection, collection: contactCollection,
}).render(); }).render();
this.friendListView.listenTo( this.contactListView.listenTo(
friendCollection, contactCollection,
'add change:timestamp change:name change:number change:profileName', 'add change:timestamp change:name change:number change:profileName',
this.friendListView.updateLocation this.contactListView.updateLocation
); );
this.listenTo( this.listenTo(
friendCollection, contactCollection,
'remove', 'remove',
this.closeConversation this.contactListView.removeItem
); );
// Search // Search
@ -212,7 +212,7 @@
extension.windows.onClosed(() => { extension.windows.onClosed(() => {
this.inboxListView.stopListening(); this.inboxListView.stopListening();
this.friendListView.stopListening(); this.contactListView.stopListening();
}); });
if (extension.expired()) { if (extension.expired()) {
@ -344,7 +344,6 @@
closeConversation(conversation) { closeConversation(conversation) {
if (conversation) { if (conversation) {
this.inboxListView.removeItem(conversation); this.inboxListView.removeItem(conversation);
this.friendListView.removeItem(conversation);
this.conversation_stack.close(conversation); this.conversation_stack.close(conversation);
} }
}, },

@ -54,7 +54,7 @@
} }
.content { .content {
overflow-y: scroll; overflow-y: auto;
max-height: calc(100% - 88px); max-height: calc(100% - 88px);
min-height: 0px; min-height: 0px;
flex: 1 1 auto; flex: 1 1 auto;
@ -85,6 +85,7 @@
margin-top: 1px; margin-top: 1px;
margin-bottom: 1px; margin-bottom: 1px;
overflow: hidden; overflow: hidden;
user-select: none;
} }
.section-toggle::after { .section-toggle::after {

@ -68,6 +68,10 @@ body.dark-theme {
color: $color-dark-05; color: $color-dark-05;
border: 1px solid $color-light-60; border: 1px solid $color-light-60;
outline: 0; outline: 0;
&[disabled='disabled'] {
background: $color-light-90;
}
} }
} }

Loading…
Cancel
Save