From ed709f52d12b4108200ccf76c2e76a2bf75c78b9 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 7 Nov 2017 16:42:43 +0000 Subject: [PATCH 1/3] Use the getProfileInfo API for group inviter profile --- src/components/structures/GroupView.js | 46 ++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 24aa552890..97d842729b 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -450,6 +450,11 @@ export default React.createClass({ }, _initGroupStore: function(groupId) { + const group = MatrixClientPeg.get().getGroup(groupId); + if (group && group.inviter && group.inviter.userId) { + this._fetchInviterProfile(group.inviter.userId); + } + this._groupStore = GroupStoreCache.getGroupStore(MatrixClientPeg.get(), groupId); this._groupStore.registerListener(() => { const summary = this._groupStore.getSummary(); @@ -481,6 +486,26 @@ export default React.createClass({ }); }, + _fetchInviterProfile(userId) { + this.setState({ + inviterProfileBusy: true, + }); + MatrixClientPeg.get().getProfileInfo(userId).then((resp) => { + this.setState({ + inviterProfile: { + avatarUrl: resp.avatar_url, + displayName: resp.displayname, + }, + }); + }).catch((e) => { + console.error('Error getting group inviter profile', e); + }).finally(() => { + this.setState({ + inviterProfileBusy: false, + }); + }); + }, + _onShowRhsClick: function(ev) { dis.dispatch({ action: 'show_right_panel' }); }, @@ -769,20 +794,37 @@ export default React.createClass({ _getMembershipSection: function() { const Spinner = sdk.getComponent("elements.Spinner"); + const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); const group = MatrixClientPeg.get().getGroup(this.props.groupId); if (!group) return null; if (group.myMembership === 'invite') { - if (this.state.membershipBusy) { + if (this.state.membershipBusy || this.state.inviterProfileBusy) { return
; } + const httpInviterAvatar = this.state.inviterProfile ? + MatrixClientPeg.get().mxcUrlToHttp( + this.state.inviterProfile.avatarUrl, 36, 36, + ) : null; + + let inviterName = group.inviter.userId; + if(this.state.inviterProfile) { + inviterName = this.state.inviterProfile.displayName || group.inviter.userId; + } return
- { _t("%(inviter)s has invited you to join this community", {inviter: group.inviter.userId}) } + + { _t("%(inviter)s has invited you to join this community", { + inviter: inviterName, + }) }
Date: Wed, 8 Nov 2017 10:07:43 +0000 Subject: [PATCH 2/3] inviterProfile = null initially --- src/components/structures/GroupView.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 97d842729b..c1510ccf3a 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -417,6 +417,7 @@ export default React.createClass({ uploadingAvatar: false, membershipBusy: false, publicityBusy: false, + inviterProfile: null, }; }, From 4bb083d9599a48e9a4b17abbb5f7de67897c321e Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 8 Nov 2017 10:08:04 +0000 Subject: [PATCH 3/3] Style --- src/components/structures/GroupView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index c1510ccf3a..a52f45fe95 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -812,7 +812,7 @@ export default React.createClass({ ) : null; let inviterName = group.inviter.userId; - if(this.state.inviterProfile) { + if (this.state.inviterProfile) { inviterName = this.state.inviterProfile.displayName || group.inviter.userId; } return