Refactor components for the main content section

Each conversation views now manages its own separate elements
rather than all binding to a shared #conversation element, and
similarly for message composition ui.

Also includes the beginnings of group creation UI (not working yet),
featuring bootstrap-tagsinput field for entering group recipients
This commit is contained in:
lilia 2014-08-10 23:34:29 -07:00
parent 28e16aaae8
commit c034ac8267
9 changed files with 216 additions and 44 deletions

View file

@ -48,26 +48,9 @@ var Whisper = Whisper || {};
if (decrypted.message.timestamp > thread.get('timestamp')) {
thread.set('timestamp', decrypted.message.timestamp);
}
thread.set('unreadCount', thread.get('unreadCount') + 1);
thread.set('active', true);
thread.save();
return m;
},
addOutgoingMessage: function(message, thread) {
var m = thread.messages().add({
threadId: thread.id,
body: message,
type: 'outgoing',
timestamp: new Date().getTime()
});
m.save();
thread.set('timestamp', new Date().getTime());
thread.set('unreadCount', 0);
thread.set('active', true);
thread.save();
thread.save({unreadCount: thread.get('unreadCount') + 1, active: true});
return m;
}
}))();
})()

View file

@ -21,7 +21,15 @@ var Whisper = Whisper || {};
},
sendMessage: function(message) {
var m = Whisper.Messages.addOutgoingMessage(message, this);
this.messages().add({ type: 'outgoing',
body: message,
threadId: this.id,
timestamp: new Date().getTime() }).save();
this.save({ timestamp: new Date().getTime(),
unreadCount: 0,
active: true});
if (this.get('type') == 'private') {
var promise = textsecure.messaging.sendMessageToNumber(this.get('id'), message, []);
}
@ -57,6 +65,18 @@ var Whisper = Whisper || {};
return thread;
},
createGroup: function(recipients, name) {
var group = textsecure.storage.groups.createNewGroup(numbers);
var attributes = {};
attributes = {
id : group.id,
name : name,
numbers : group.numbers,
type : 'group',
};
return this.findOrCreate(attributes);
},
findOrCreateForRecipient: function(recipient) {
var attributes = {};
attributes = {