diff --git a/index.html b/index.html
index 1f1ea90f5985..e81c946aa268 100644
--- a/index.html
+++ b/index.html
@@ -68,7 +68,7 @@
+
diff --git a/js/models/conversations.js b/js/models/conversations.js
index 812e7d0789d6..520deffa04cf 100644
--- a/js/models/conversations.js
+++ b/js/models/conversations.js
@@ -131,15 +131,16 @@
return -m.get('timestamp');
},
- createGroup: function(recipients, name) {
+ createGroup: function(recipients, name, avatar) {
var attributes = {};
attributes = {
name : name,
members : recipients,
type : 'group',
+ avatar : avatar
};
var conversation = this.add(attributes, {merge: true});
- return textsecure.messaging.createGroup(recipients, name).then(function(groupId) {
+ return textsecure.messaging.createGroup(recipients, name, avatar).then(function(groupId) {
conversation.save({
id : getString(groupId),
groupId : getString(groupId)
diff --git a/js/views/attachment_view.js b/js/views/attachment_view.js
new file mode 100644
index 000000000000..03b2b2484e7a
--- /dev/null
+++ b/js/views/attachment_view.js
@@ -0,0 +1,41 @@
+/* vim: ts=4:sw=4:expandtab
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+(function () {
+ 'use strict';
+
+ Whisper.AttachmentView = Backbone.View.extend({
+ tagName: "img",
+ encode: function () {
+ return new Promise(function(resolve, reject) {
+ var blob = new Blob([this.model.data], { type: this.model.contentType });
+ var FR = new FileReader();
+ FR.onload = function(e) {
+ resolve(e.target.result);
+ };
+ FR.onerror = reject;
+ FR.readAsDataURL(blob);
+ }.bind(this));
+ },
+ render: function() {
+ this.encode().then(function(base64) {
+ this.$el.attr('src', base64);
+ this.$el.trigger('update');
+ }.bind(this));
+ return this;
+ }
+ });
+
+})();
diff --git a/js/views/conversation_list_item_view.js b/js/views/conversation_list_item_view.js
index 1f167d80cded..62b7cca17661 100644
--- a/js/views/conversation_list_item_view.js
+++ b/js/views/conversation_list_item_view.js
@@ -32,11 +32,15 @@ var Whisper = Whisper || {};
this.$el.html(
Mustache.render(this.template, {
contact_name: this.model.get('name') || this.model.get('members') || this.model.id,
- contact_avatar: this.model.get('image'),
last_message: this.model.get('lastMessage'),
last_message_timestamp: moment(this.model.get('timestamp')).format('MMM D')
})
);
+ if (this.model.get('avatar')) {
+ this.$el.find('.avatar').append(
+ new Whisper.AttachmentView({model: this.model.get('avatar')}).render().el
+ );
+ }
return this;
}
diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js
index 6b19b53e2121..70672443299a 100644
--- a/js/views/file_input_view.js
+++ b/js/views/file_input_view.js
@@ -14,7 +14,9 @@ var Whisper = Whisper || {};
},
addThumb: function(e) {
- this.$el.append($('').attr( "src", e.target.result ));
+ this.$el.append(
+ $('').attr( "src", e.target.result ).addClass('preview')
+ );
},
previewImages: function() {
diff --git a/js/views/message_view.js b/js/views/message_view.js
index ab9d1c0e97b7..dd44e768973d 100644
--- a/js/views/message_view.js
+++ b/js/views/message_view.js
@@ -16,28 +16,6 @@
(function () {
'use strict';
- var AttachmentView = Backbone.View.extend({
- tagName: "img",
- encode: function () {
- return new Promise(function(resolve, reject) {
- var blob = new Blob([this.model.data], { type: this.model.contentType });
- var FR = new FileReader();
- FR.onload = function(e) {
- resolve(e.target.result);
- };
- FR.onerror = reject;
- FR.readAsDataURL(blob);
- }.bind(this));
- },
- render: function() {
- this.encode().then(function(base64) {
- this.$el.attr('src', base64);
- this.$el.trigger('update');
- }.bind(this));
- return this;
- }
- });
-
var ErrorView = Backbone.View.extend({
className: 'error',
events: {
@@ -90,7 +68,7 @@
this.$el.find('.attachments').append(
this.model.get('attachments').map(function(attachment) {
- return new AttachmentView({model: attachment}).render().el;
+ return new Whisper.AttachmentView({model: attachment}).render().el;
})
);
diff --git a/js/views/new_group_view.js b/js/views/new_group_view.js
index 81002b417980..a9ed1bddcbea 100644
--- a/js/views/new_group_view.js
+++ b/js/views/new_group_view.js
@@ -26,7 +26,10 @@ var Whisper = Whisper || {};
this.$el.html($(Mustache.render(this.template)));
this.input = this.$el.find('input.number');
new Whisper.GroupRecipientsInputView({el: this.$el.find('input.numbers')}).$el.appendTo(this.$el);
+ this.fileInput = new Whisper.FileInputView({el: this.$el.find('.attachments')});
+ this.avatarInput = new Whisper.FileInputView({el: this.$el.find('.group-avatar')});
},
+
events: {
'submit .send': 'send',
'close': 'remove'
@@ -36,12 +39,20 @@ var Whisper = Whisper || {};
e.preventDefault();
var numbers = this.$el.find('input.numbers').val().split(',');
var name = this.$el.find('input.name').val();
+ var message_input = this.$el.find('input.send-message');
+ var message = message_input.val();
var view = this;
- this.collection.createGroup(numbers, name).then(function(convo){
- convo.sendMessage(view.$el.find('input.send-message').val());
- view.remove();
- convo.trigger('render');
- });
+ if (message.length > 0 || this.fileInput.hasFiles()) {
+ this.avatarInput.getFiles().then(function(avatar_files) {
+ view.collection.createGroup(numbers, name, avatar_files[0]).then(function(convo){
+ view.fileInput.getFiles().then(function(attachments) {
+ convo.sendMessage(view.$el.find('input.send-message').val());
+ });
+ convo.trigger('render');
+ });
+ });
+ }
+ this.remove();
}
});
diff --git a/stylesheets/index.css b/stylesheets/index.css
index ae4cb2da790b..c536582259e8 100644
--- a/stylesheets/index.css
+++ b/stylesheets/index.css
@@ -73,7 +73,7 @@ li.entry img {
margin-top: 5px;
}
-.send .attachments img {
+img.preview {
width: 30px;
height: 30px;
}
diff --git a/stylesheets/manifest.css b/stylesheets/manifest.css
index 2289f6dfdead..214cfbb1fb81 100644
--- a/stylesheets/manifest.css
+++ b/stylesheets/manifest.css
@@ -231,6 +231,9 @@ ul.discussion {
background-color: #00badd;
color: white; }
+.avatar img {
+ max-width: 100%; }
+
@media screen and (min-width: 320px) {
.send-message-area {
position: fixed;
diff --git a/stylesheets/view/_conversation.scss b/stylesheets/view/_conversation.scss
index 5d0a61a39149..a4b851939d41 100644
--- a/stylesheets/view/_conversation.scss
+++ b/stylesheets/view/_conversation.scss
@@ -75,4 +75,8 @@ ul.discussion {
}
&.sent .volley {
}
-}
\ No newline at end of file
+}
+
+.avatar img {
+ max-width: 100%;
+}
diff --git a/test/index.html b/test/index.html
index b97d1f1be0ad..9bd8e99b0611 100644
--- a/test/index.html
+++ b/test/index.html
@@ -150,6 +150,7 @@
+