From 44007ca58f4788815d51a5cd63358d9b015103cd Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 13 Jan 2015 13:27:18 -1000 Subject: [PATCH] Add rudimentary ui for sending a group update --- index.html | 11 ++++++ js/libtextsecure.js | 28 ++++++++++++++ js/views/conversation_view.js | 15 +++++++- js/views/new_group_update_view.js | 61 +++++++++++++++++++++++++++++++ libtextsecure/sendmessage.js | 28 ++++++++++++++ 5 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 js/views/new_group_update_view.js diff --git a/index.html b/index.html index 0dd070ff..5937a576 100644 --- a/index.html +++ b/index.html @@ -32,6 +32,16 @@
+ + diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 914e511f..5c741168 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -8319,6 +8319,34 @@ window.textsecure.messaging = function() { } } + self.updateGroup = function(groupId, name, avatar, numbers) { + var proto = new textsecure.protobuf.PushMessageContent(); + proto.group = new textsecure.protobuf.PushMessageContent.GroupContext(); + + proto.group.id = toArrayBuffer(groupId); + proto.group.type = textsecure.protobuf.PushMessageContent.GroupContext.Type.UPDATE; + proto.group.name = name; + + var numbers = textsecure.storage.groups.addNumbers(groupId, numbers); + if (numbers === undefined) { + return new Promise(function(resolve, reject) { reject(new Error("Unknown Group")); }); + } + proto.group.members = numbers; + + if (avatar !== undefined) { + return makeAttachmentPointer(avatar).then(function(attachment) { + proto.group.avatar = attachment; + return sendGroupProto(numbers, proto).then(function() { + return proto.group.id; + }); + }); + } else { + return sendGroupProto(numbers, proto).then(function() { + return proto.group.id; + }); + } + } + self.addNumberToGroup = function(groupId, number) { var proto = new textsecure.protobuf.PushMessageContent(); proto.group = new textsecure.protobuf.PushMessageContent.GroupContext(); diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index fff899c0..ed07d237 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -38,13 +38,26 @@ if (this.model.get('type') === 'group') { this.$el.addClass('group'); + this.$el.find('.send-message-area').append($('