From caddb8dc09ecd0477a84d08ba41188d2e5cf0e2a Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 23 Mar 2015 17:33:46 -0700 Subject: [PATCH] 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. --- js/views/new_conversation_view.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/js/views/new_conversation_view.js b/js/views/new_conversation_view.js index 30ceb35c..f93ade58 100644 --- a/js/views/new_conversation_view.js +++ b/js/views/new_conversation_view.js @@ -112,22 +112,27 @@ 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 = { + id: groupId, + groupId: groupId, type: 'group', name: name, - avatar: avatarFiles[0], - members: this.getRecipients().pluck('id') + avatar: avatarFile, + members: members }; - return textsecure.messaging.createGroup( - attributes.members, attributes.name, attributes.avatar - ).then(function(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)); + var group = new Whisper.Conversation(attributes); + group.save().then(function() { + this.trigger('open', {modelId: groupId}); }.bind(this)); + textsecure.messaging.updateGroup( + group.id, + group.get('name'), + group.get('avatar'), + group.get('members') + ); }.bind(this)); },