diff --git a/background.html b/background.html
index c215ab2736..2507aab720 100644
--- a/background.html
+++ b/background.html
@@ -202,6 +202,7 @@
+
diff --git a/js/background.js b/js/background.js
index 441cc22440..621751232e 100644
--- a/js/background.js
+++ b/js/background.js
@@ -115,12 +115,12 @@
e.args.push(message.id);
message.save({ errors : [e] }).then(function() {
extension.trigger('message', message);
- openConversation(conversation.id);
+ notifyConversation(message);
});
} else if (e.message === 'Bad MAC') {
message.save({ errors : [ _.pick(e, ['name', 'message'])]}).then(function() {
extension.trigger('message', message);
- openConversation(conversation.id);
+ notifyConversation(message);
});
} else {
console.log(e);
@@ -220,7 +220,7 @@
conversation.save().then(function() {
message.save().then(function() {
extension.trigger('message', message); // notify frontend listeners
- openConversation(conversation.id);
+ notifyConversation(message);
});
});
});
diff --git a/js/models/conversations.js b/js/models/conversations.js
index 817042344f..629552a062 100644
--- a/js/models/conversations.js
+++ b/js/models/conversations.js
@@ -36,6 +36,8 @@
this.messageCollection = new Whisper.MessageCollection([], {
conversation: this
});
+
+ this.on('change:avatar', this.updateAvatarUrl);
},
validate: function(attributes, options) {
@@ -190,6 +192,28 @@
},
isPrivate: function() {
return this.get('type') === 'private';
+ },
+
+ updateAvatarUrl: function() {
+ if (this.avatarUrl) {
+ URL.revokeObjectURL(this.avatarUrl);
+ this.avatarUrl = null;
+ }
+ var avatar = this.get('avatar');
+ if (avatar) {
+ this.avatarUrl = URL.createObjectURL(
+ new Blob([avatar.data], {type: avatar.contentType})
+ );
+ } else {
+ this.avatarUrl = null;
+ }
+ },
+
+ getAvatarUrl: function() {
+ if (this.avatarUrl === undefined) {
+ this.updateAvatarUrl();
+ }
+ return this.avatarUrl || '/images/default.png';
}
});
diff --git a/js/notifications.js b/js/notifications.js
new file mode 100644
index 0000000000..599d8e2efc
--- /dev/null
+++ b/js/notifications.js
@@ -0,0 +1,36 @@
+/* vim: ts=4:sw=4
+ *
+ * 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