From b756332f89a76fdc7b7e7149c636406e5c5967a1 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 19 Feb 2020 14:00:20 +1100 Subject: [PATCH] fix group member dialog and refresh right after group avatar update --- js/modules/loki_app_dot_net_api.js | 11 +++---- js/views/create_group_dialog_view.js | 43 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/js/modules/loki_app_dot_net_api.js b/js/modules/loki_app_dot_net_api.js index 320e16192..6a92618fe 100644 --- a/js/modules/loki_app_dot_net_api.js +++ b/js/modules/loki_app_dot_net_api.js @@ -1276,11 +1276,6 @@ class LokiPublicChannelAPI { ); // update group this.conversation.set('avatar', newAttributes.avatar); - - await window.Signal.Data.updateConversation(this.conversation.id, this.conversation.attributes, { - Conversation: Whisper.Conversation, - }); - this.conversation.trigger('change'); } // is it mutable? // who are the moderators? @@ -1290,6 +1285,12 @@ class LokiPublicChannelAPI { if (data.counts && Number.isInteger(data.counts.subscribers)) { this.conversation.setSubscriberCount(data.counts.subscribers); } + + await window.Signal.Data.updateConversation(this.conversation.id, this.conversation.attributes, { + Conversation: Whisper.Conversation, + }); + await this.pollForChannelOnce(); + this.conversation.trigger('change'); } // get moderation actions diff --git a/js/views/create_group_dialog_view.js b/js/views/create_group_dialog_view.js index 193fd1ed0..639711ee3 100644 --- a/js/views/create_group_dialog_view.js +++ b/js/views/create_group_dialog_view.js @@ -60,6 +60,7 @@ this.onSubmit = this.onSubmit.bind(this); this.isPublic = groupConvo.isPublic(); this.groupId = groupConvo.id; + this.members = groupConvo.get('members') || []; const ourPK = textsecure.storage.user.getNumber(); @@ -76,27 +77,6 @@ this.isAdmin = groupConvo.isModerator( window.storage.get('primaryDevicePubKey') ); - // zero out friendList for now - this.friendsAndMembers = []; - this.existingMembers = []; - } else { - const convos = window.getConversations().models.filter(d => !!d); - - this.existingMembers = groupConvo.get('members') || []; - // Show a contact if they are our friend or if they are a member - this.friendsAndMembers = convos.filter( - d => this.existingMembers.includes(d.id) && d.isPrivate() && !d.isMe() - ); - this.friendsAndMembers = _.uniq( - this.friendsAndMembers, - true, - d => d.id - ); - - // at least make sure it's an array - if (!Array.isArray(this.existingMembers)) { - this.existingMembers = []; - } } this.$el.focus(); @@ -140,7 +120,6 @@ this.isPublic = groupConvo.isPublic(); this.groupId = groupConvo.id; this.avatarPath = groupConvo.getAvatarPath(); - this.members = groupConvo.get('members') || []; if (this.isPublic) { this.titleText = `${i18n('updatePublicGroupDialogTitle')}: ${ @@ -151,9 +130,29 @@ this.isAdmin = groupConvo.isModerator( window.storage.get('primaryDevicePubKey') ); + // zero out friendList for now + this.friendsAndMembers = []; + this.existingMembers = []; } else { this.titleText = i18n('updateGroupDialogTitle'); this.isAdmin = groupConvo.get('groupAdmins').includes(ourPK); + const convos = window.getConversations().models.filter(d => !!d); + + this.existingMembers = groupConvo.get('members') || []; + // Show a contact if they are our friend or if they are a member + this.friendsAndMembers = convos.filter( + d => this.existingMembers.includes(d.id) && d.isPrivate() && !d.isMe() + ); + this.friendsAndMembers = _.uniq( + this.friendsAndMembers, + true, + d => d.id + ); + + // at least make sure it's an array + if (!Array.isArray(this.existingMembers)) { + this.existingMembers = []; + } } this.$el.focus();