Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1509 from matrix-org/luke/groups-my-groups
Browse files Browse the repository at this point in the history
Improve MyGroups UI
  • Loading branch information
lukebarnard1 authored Oct 19, 2017
2 parents bd982cf + b0f8619 commit 877f213
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
45 changes: 37 additions & 8 deletions src/components/structures/MyGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

import React from 'react';
import {MatrixClient} from 'matrix-js-sdk';
import sdk from '../../index';
import { _t, _tJsx } from '../../languageHandler';
import withMatrixClient from '../../wrappers/withMatrixClient';
Expand All @@ -23,13 +24,31 @@ import dis from '../../dispatcher';
import PropTypes from 'prop-types';
import Modal from '../../Modal';

import FlairStore from '../../stores/FlairStore';

const GroupTile = React.createClass({
displayName: 'GroupTile',

propTypes: {
groupId: PropTypes.string.isRequired,
},

contextTypes: {
matrixClient: React.PropTypes.instanceOf(MatrixClient).isRequired,
},

getInitialState() {
return {
profile: null,
};
},

componentWillMount: function() {
FlairStore.getGroupProfileCached(this.context.matrixClient, this.props.groupId).then((profile) => {
this.setState({profile});
});
},

onClick: function(e) {
e.preventDefault();
dis.dispatch({
Expand All @@ -39,7 +58,21 @@ const GroupTile = React.createClass({
},

render: function() {
return <a onClick={this.onClick} href="#">{ this.props.groupId }</a>;
const BaseAvatar = sdk.getComponent('avatars.BaseAvatar');
const profile = this.state.profile || {};
const name = profile.name || this.props.groupId;
const desc = profile.shortDescription;
const httpUrl = profile.avatarUrl ? this.context.matrixClient.mxcUrlToHttp(profile.avatarUrl, 50, 50) : null;
return <AccessibleButton className="mx_GroupTile" onClick={this.onClick}>
<div className="mx_GroupTile_avatar">
<BaseAvatar name={name} url={httpUrl} width={50} height={50} />
</div>
<div className="mx_GroupTile_profile">
<h3 className="mx_GroupTile_name">{ name }</h3>
<div className="mx_GroupTile_desc">{ desc }</div>
<div className="mx_GroupTile_groupId">{ this.props.groupId }</div>
</div>
</AccessibleButton>;
},
});

Expand Down Expand Up @@ -83,14 +116,9 @@ export default withMatrixClient(React.createClass({
if (this.state.groups) {
const groupNodes = [];
this.state.groups.forEach((g) => {
groupNodes.push(
<div key={g}>
<GroupTile groupId={g} />
</div>,
);
groupNodes.push(<GroupTile groupId={g} />);
});
content = <div>
<div>{ _t('You are a member of these communities:') }</div>
content = <div className="mx_MyGroups_joinedGroups">
{ groupNodes }
</div>;
} else if (this.state.error) {
Expand Down Expand Up @@ -134,6 +162,7 @@ export default withMatrixClient(React.createClass({
</div>
</div>
<div className="mx_MyGroups_content">
<h3>{ _t('Your Communities') }</h3>
{ content }
</div>
</div>;
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,12 @@
"Signed Out": "Signed Out",
"For security, this session has been signed out. Please sign in again.": "For security, this session has been signed out. Please sign in again.",
"Logout": "Logout",
"You are a member of these communities:": "You are a member of these communities:",
"Error whilst fetching joined communities": "Error whilst fetching joined communities",
"Create a new community": "Create a new community",
"Create a community to represent your community! Define a set of rooms and your own custom homepage to mark out your space in the Matrix universe.": "Create a community to represent your community! Define a set of rooms and your own custom homepage to mark out your space in the Matrix universe.",
"Join an existing community": "Join an existing community",
"To join an existing community you'll have to know its community identifier; this will look something like <i>+example:matrix.org</i>.": "To join an existing community you'll have to know its community identifier; this will look something like <i>+example:matrix.org</i>.",
"Your Communities": "Your Communities",
"You have no visible notifications": "You have no visible notifications",
"Scroll to bottom of page": "Scroll to bottom of page",
"Connectivity to the server has been lost.": "Connectivity to the server has been lost.",
Expand Down
2 changes: 2 additions & 0 deletions src/stores/FlairStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class FlairStore extends EventEmitter {
this._groupProfiles[groupId] = {
groupId,
avatarUrl: profile.avatar_url,
name: profile.name,
shortDescription: profile.short_description,
};
setTimeout(() => {
delete this._groupProfiles[groupId];
Expand Down

0 comments on commit 877f213

Please sign in to comment.