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

Commit

Permalink
Display custom status messages in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Dec 12, 2018
1 parent ab65669 commit ce7969e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
19 changes: 18 additions & 1 deletion res/css/views/rooms/_RoomTile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ limitations under the License.
.mx_RoomTile_nameContainer {
display: inline-block;
width: 180px;
height: 24px;
//height: 24px;
vertical-align: middle;
}

.mx_RoomTile_subtext {
display: inline-block;
font-size: 0.8em;
padding: 0 0 0 7px;
margin: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: clip;
position: relative;
bottom: 4px;
}

.mx_RoomTile_avatar_container {
Expand Down Expand Up @@ -76,6 +89,10 @@ limitations under the License.
text-overflow: ellipsis;
}

.mx_RoomTile_hasSubtext .mx_RoomTile_avatar {
padding-top: 0;
}

.mx_RoomTile_invite {
/* color: rgba(69, 69, 69, 0.5); */
}
Expand Down
21 changes: 17 additions & 4 deletions src/components/views/rooms/EntityTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const EntityTile = React.createClass({
onClick: PropTypes.func,
suppressOnHover: PropTypes.bool,
showPresence: PropTypes.bool,
subtextLabel: PropTypes.string,
},

getDefaultProps: function() {
Expand Down Expand Up @@ -125,19 +126,31 @@ const EntityTile = React.createClass({
let nameClasses = 'mx_EntityTile_name';
if (this.props.showPresence) {
presenceLabel = <PresenceLabel activeAgo={activeAgo}
currentlyActive={this.props.presenceCurrentlyActive}
presenceState={this.props.presenceState} />;
currentlyActive={this.props.presenceCurrentlyActive}
presenceState={this.props.presenceState}/>;
nameClasses += ' mx_EntityTile_name_hover';
}
if (this.props.subtextLabel) {
presenceLabel = <span className="mx_PresenceLabel">{this.props.subtextLabel}</span>;
}
nameEl = (
<div className="mx_EntityTile_details">
<img className="mx_EntityTile_chevron" src="img/member_chevron.png" width="8" height="12" />
<img className="mx_EntityTile_chevron" src="img/member_chevron.png" width="8" height="12"/>
<EmojiText element="div" className={nameClasses} dir="auto">
{ name }
{name}
</EmojiText>
{presenceLabel}
</div>
);
} else if (this.props.subtextLabel) {
nameEl = (
<div className="mx_EntityTile_details">
<EmojiText element="div" className="mx_EntityTile_name" dir="auto">
{name}
</EmojiText>
<span className="mx_PresenceLabel">{this.props.subtextLabel}</span>
</div>
);
} else {
nameEl = (
<EmojiText element="div" className="mx_EntityTile_name" dir="auto">{ name }</EmojiText>
Expand Down
5 changes: 4 additions & 1 deletion src/components/views/rooms/MemberTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module.exports = React.createClass({
const name = this._getDisplayName();
const active = -1;
const presenceState = member.user ? member.user.presence : null;
const statusMessage = member.user ? member.user.statusMessage : null;

const av = (
<MemberAvatar member={member} width={36} height={36} />
Expand All @@ -106,7 +107,9 @@ module.exports = React.createClass({
presenceLastTs={member.user ? member.user.lastPresenceTs : 0}
presenceCurrentlyActive={member.user ? member.user.currentlyActive : false}
avatarJsx={av} title={this.getPowerLabel()} onClick={this.onClick}
name={name} powerStatus={powerStatus} showPresence={this.props.showPresence} />
name={name} powerStatus={powerStatus} showPresence={this.props.showPresence}
subtextLabel={statusMessage}
/>
);
},
});
16 changes: 16 additions & 0 deletions src/components/views/rooms/RoomTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ module.exports = React.createClass({
const mentionBadges = this.props.highlight && this._shouldShowMentionBadge();
const badges = notifBadges || mentionBadges;

const isJoined = this.props.room.getMyMembership() === "join";
const looksLikeDm = this.props.room.currentState.getMembers().length === 2;
let subtext = null;
if (!isInvite && isJoined && looksLikeDm) {
const selfId = MatrixClientPeg.get().getUserId();
const otherMember = this.props.room.currentState.getMembersExcept([selfId])[0];
if (otherMember.user && otherMember.user.statusMessage) {
subtext = otherMember.user.statusMessage;
}
}

const classes = classNames({
'mx_RoomTile': true,
'mx_RoomTile_selected': this.state.selected,
Expand All @@ -261,6 +272,7 @@ module.exports = React.createClass({
'mx_RoomTile_menuDisplayed': this.state.menuDisplayed,
'mx_RoomTile_noBadges': !badges,
'mx_RoomTile_transparent': this.props.transparent,
'mx_RoomTile_hasSubtext': !!subtext && !this.props.isCollapsed,
});

const avatarClasses = classNames({
Expand Down Expand Up @@ -291,6 +303,7 @@ module.exports = React.createClass({

const EmojiText = sdk.getComponent('elements.EmojiText');
let label;
let subtextLabel;
let tooltip;
if (!this.props.collapsed) {
const nameClasses = classNames({
Expand All @@ -299,6 +312,8 @@ module.exports = React.createClass({
'mx_RoomTile_badgeShown': badges || this.state.badgeHover || this.state.menuDisplayed,
});

subtextLabel = subtext ? <span className="mx_RoomTile_subtext">{ subtext }</span> : null;

if (this.state.selected) {
const nameSelected = <EmojiText>{ name }</EmojiText>;

Expand Down Expand Up @@ -339,6 +354,7 @@ module.exports = React.createClass({
</div>
<div className="mx_RoomTile_nameContainer">
{ label }
{ subtextLabel }
{ badge }
</div>
{ /* { incomingCallBox } */ }
Expand Down

0 comments on commit ce7969e

Please sign in to comment.