Properly download new group avatars

This commit is contained in:
Scott Nonnenberg 2019-06-24 11:51:33 -07:00 committed by Ken Powers
parent d97dae6a87
commit ab2cc6ee53
2 changed files with 7 additions and 4 deletions

View file

@ -1480,7 +1480,7 @@
}; };
} }
let group = this.get('group'); let group = this.get('group_update');
if (group && group.avatar) { if (group && group.avatar) {
group = { group = {
...group, ...group,

View file

@ -364,10 +364,11 @@ async function _addAttachmentToMessage(message, attachment, { type, index }) {
} }
if (type === 'group-avatar') { if (type === 'group-avatar') {
const conversationId = message.get('conversationid'); const conversationId = message.get('conversationId');
const conversation = ConversationController.get(conversationId); const conversation = ConversationController.get(conversationId);
if (!conversation) { if (!conversation) {
logger.warn("_addAttachmentToMessage: conversation didn't exist"); logger.warn("_addAttachmentToMessage: conversation didn't exist");
return;
} }
const existingAvatar = conversation.get('avatar'); const existingAvatar = conversation.get('avatar');
@ -375,11 +376,13 @@ async function _addAttachmentToMessage(message, attachment, { type, index }) {
await Signal.Migrations.deleteAttachmentData(existingAvatar.path); await Signal.Migrations.deleteAttachmentData(existingAvatar.path);
} }
const data = await Signal.Migrations.loadAttachmentData(attachment.path); const loadedAttachment = await Signal.Migrations.loadAttachmentData(
attachment
);
conversation.set({ conversation.set({
avatar: { avatar: {
...attachment, ...attachment,
hash: await computeHash(data), hash: await computeHash(loadedAttachment.data),
}, },
}); });
await Signal.Data.updateConversation( await Signal.Data.updateConversation(