Smoother group create experience

Previously there was a long pause between confirming the group details
and opening the conversation. Fix by first saving/opening the
conversation, rather than waiting for the initial group update to finish
transmitting.
This commit is contained in:
lilia 2015-03-23 17:33:46 -07:00
parent 74e01c2a95
commit caddb8dc09

View file

@ -112,22 +112,27 @@
return; return;
} }
return this.avatarInput.getFiles().then(function(avatarFiles) { return this.avatarInput.getFile().then(function(avatarFile) {
var members = this.getRecipients().pluck('id');
var groupId = textsecure.storage.groups.createNewGroup(members).id;
var attributes = { var attributes = {
id: groupId,
groupId: groupId,
type: 'group', type: 'group',
name: name, name: name,
avatar: avatarFiles[0], avatar: avatarFile,
members: this.getRecipients().pluck('id') members: members
}; };
return textsecure.messaging.createGroup( var group = new Whisper.Conversation(attributes);
attributes.members, attributes.name, attributes.avatar group.save().then(function() {
).then(function(groupId) { this.trigger('open', {modelId: groupId});
var id = getString(groupId);
var group = new Whisper.Conversation(attributes);
group.save({ id: id, groupId: id }).then(function() {
this.trigger('open', {modelId: id});
}.bind(this));
}.bind(this)); }.bind(this));
textsecure.messaging.updateGroup(
group.id,
group.get('name'),
group.get('avatar'),
group.get('members')
);
}.bind(this)); }.bind(this));
}, },