mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
Display custom status messages in the UI
Part of https://github.com/vector-im/riot-web/issues/1528
This commit is contained in:
parent
ab6566980f
commit
ce7969e3d5
4 changed files with 55 additions and 6 deletions
|
@ -35,7 +35,20 @@ limitations under the License.
|
||||||
.mx_RoomTile_nameContainer {
|
.mx_RoomTile_nameContainer {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 180px;
|
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 {
|
.mx_RoomTile_avatar_container {
|
||||||
|
@ -76,6 +89,10 @@ limitations under the License.
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_RoomTile_hasSubtext .mx_RoomTile_avatar {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.mx_RoomTile_invite {
|
.mx_RoomTile_invite {
|
||||||
/* color: rgba(69, 69, 69, 0.5); */
|
/* color: rgba(69, 69, 69, 0.5); */
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ const EntityTile = React.createClass({
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
suppressOnHover: PropTypes.bool,
|
suppressOnHover: PropTypes.bool,
|
||||||
showPresence: PropTypes.bool,
|
showPresence: PropTypes.bool,
|
||||||
|
subtextLabel: PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -125,19 +126,31 @@ const EntityTile = React.createClass({
|
||||||
let nameClasses = 'mx_EntityTile_name';
|
let nameClasses = 'mx_EntityTile_name';
|
||||||
if (this.props.showPresence) {
|
if (this.props.showPresence) {
|
||||||
presenceLabel = <PresenceLabel activeAgo={activeAgo}
|
presenceLabel = <PresenceLabel activeAgo={activeAgo}
|
||||||
currentlyActive={this.props.presenceCurrentlyActive}
|
currentlyActive={this.props.presenceCurrentlyActive}
|
||||||
presenceState={this.props.presenceState} />;
|
presenceState={this.props.presenceState}/>;
|
||||||
nameClasses += ' mx_EntityTile_name_hover';
|
nameClasses += ' mx_EntityTile_name_hover';
|
||||||
}
|
}
|
||||||
|
if (this.props.subtextLabel) {
|
||||||
|
presenceLabel = <span className="mx_PresenceLabel">{this.props.subtextLabel}</span>;
|
||||||
|
}
|
||||||
nameEl = (
|
nameEl = (
|
||||||
<div className="mx_EntityTile_details">
|
<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">
|
<EmojiText element="div" className={nameClasses} dir="auto">
|
||||||
{ name }
|
{name}
|
||||||
</EmojiText>
|
</EmojiText>
|
||||||
{presenceLabel}
|
{presenceLabel}
|
||||||
</div>
|
</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 {
|
} else {
|
||||||
nameEl = (
|
nameEl = (
|
||||||
<EmojiText element="div" className="mx_EntityTile_name" dir="auto">{ name }</EmojiText>
|
<EmojiText element="div" className="mx_EntityTile_name" dir="auto">{ name }</EmojiText>
|
||||||
|
|
|
@ -84,6 +84,7 @@ module.exports = React.createClass({
|
||||||
const name = this._getDisplayName();
|
const name = this._getDisplayName();
|
||||||
const active = -1;
|
const active = -1;
|
||||||
const presenceState = member.user ? member.user.presence : null;
|
const presenceState = member.user ? member.user.presence : null;
|
||||||
|
const statusMessage = member.user ? member.user.statusMessage : null;
|
||||||
|
|
||||||
const av = (
|
const av = (
|
||||||
<MemberAvatar member={member} width={36} height={36} />
|
<MemberAvatar member={member} width={36} height={36} />
|
||||||
|
@ -106,7 +107,9 @@ module.exports = React.createClass({
|
||||||
presenceLastTs={member.user ? member.user.lastPresenceTs : 0}
|
presenceLastTs={member.user ? member.user.lastPresenceTs : 0}
|
||||||
presenceCurrentlyActive={member.user ? member.user.currentlyActive : false}
|
presenceCurrentlyActive={member.user ? member.user.currentlyActive : false}
|
||||||
avatarJsx={av} title={this.getPowerLabel()} onClick={this.onClick}
|
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}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -251,6 +251,17 @@ module.exports = React.createClass({
|
||||||
const mentionBadges = this.props.highlight && this._shouldShowMentionBadge();
|
const mentionBadges = this.props.highlight && this._shouldShowMentionBadge();
|
||||||
const badges = notifBadges || mentionBadges;
|
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({
|
const classes = classNames({
|
||||||
'mx_RoomTile': true,
|
'mx_RoomTile': true,
|
||||||
'mx_RoomTile_selected': this.state.selected,
|
'mx_RoomTile_selected': this.state.selected,
|
||||||
|
@ -261,6 +272,7 @@ module.exports = React.createClass({
|
||||||
'mx_RoomTile_menuDisplayed': this.state.menuDisplayed,
|
'mx_RoomTile_menuDisplayed': this.state.menuDisplayed,
|
||||||
'mx_RoomTile_noBadges': !badges,
|
'mx_RoomTile_noBadges': !badges,
|
||||||
'mx_RoomTile_transparent': this.props.transparent,
|
'mx_RoomTile_transparent': this.props.transparent,
|
||||||
|
'mx_RoomTile_hasSubtext': !!subtext && !this.props.isCollapsed,
|
||||||
});
|
});
|
||||||
|
|
||||||
const avatarClasses = classNames({
|
const avatarClasses = classNames({
|
||||||
|
@ -291,6 +303,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
const EmojiText = sdk.getComponent('elements.EmojiText');
|
const EmojiText = sdk.getComponent('elements.EmojiText');
|
||||||
let label;
|
let label;
|
||||||
|
let subtextLabel;
|
||||||
let tooltip;
|
let tooltip;
|
||||||
if (!this.props.collapsed) {
|
if (!this.props.collapsed) {
|
||||||
const nameClasses = classNames({
|
const nameClasses = classNames({
|
||||||
|
@ -299,6 +312,8 @@ module.exports = React.createClass({
|
||||||
'mx_RoomTile_badgeShown': badges || this.state.badgeHover || this.state.menuDisplayed,
|
'mx_RoomTile_badgeShown': badges || this.state.badgeHover || this.state.menuDisplayed,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
subtextLabel = subtext ? <span className="mx_RoomTile_subtext">{ subtext }</span> : null;
|
||||||
|
|
||||||
if (this.state.selected) {
|
if (this.state.selected) {
|
||||||
const nameSelected = <EmojiText>{ name }</EmojiText>;
|
const nameSelected = <EmojiText>{ name }</EmojiText>;
|
||||||
|
|
||||||
|
@ -339,6 +354,7 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_RoomTile_nameContainer">
|
<div className="mx_RoomTile_nameContainer">
|
||||||
{ label }
|
{ label }
|
||||||
|
{ subtextLabel }
|
||||||
{ badge }
|
{ badge }
|
||||||
</div>
|
</div>
|
||||||
{ /* { incomingCallBox } */ }
|
{ /* { incomingCallBox } */ }
|
||||||
|
|
Loading…
Reference in a new issue