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

Support MSC3026 busy presence #8043

Merged
merged 3 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions res/css/views/avatars/_DecoratedRoomAvatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ limitations under the License.
background-color: $presence-away;
}

.mx_DecoratedRoomAvatar_icon_busy::before {
background-color: $presence-busy;
}

.mx_NotificationBadge, .mx_RoomTile_badgeContainer {
position: absolute;
top: 0;
Expand Down
1 change: 1 addition & 0 deletions res/themes/legacy-light/css/_legacy-light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ $roomtile-selected-bg-color: #fff;

$presence-away: #d9b072;
$presence-offline: #e3e8f0;
$presence-busy: #FF5B55;

// Legacy theme backports
$accent: #0DBD8B;
Expand Down
1 change: 1 addition & 0 deletions res/themes/light/css/_light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ $rte-code-bg-color: rgba(0, 0, 0, 0.04);
// ********************
$presence-away: #d9b072;
$presence-offline: $quinary-content;
$presence-busy: $alert;
// ********************

// Inputs
Expand Down
7 changes: 6 additions & 1 deletion src/components/views/avatars/DecoratedRoomAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum Icon {
PresenceOnline = "ONLINE",
PresenceAway = "AWAY",
PresenceOffline = "OFFLINE",
PresenceBusy = "BUSY",
}

function tooltipText(variant: Icon) {
Expand All @@ -69,6 +70,8 @@ function tooltipText(variant: Icon) {
return _t("Away");
case Icon.PresenceOffline:
return _t("Offline");
case Icon.PresenceBusy:
return _t("Busy");
}
}

Expand Down Expand Up @@ -141,7 +144,9 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
let icon = Icon.None;

const isOnline = this.dmUser.currentlyActive || this.dmUser.presence === 'online';
if (isOnline) {
if (["org.matrix.msc3026.busy", "busy"].includes(this.dmUser.presence)) {
dbkr marked this conversation as resolved.
Show resolved Hide resolved
icon = Icon.PresenceBusy;
} else if (isOnline) {
icon = Icon.PresenceOnline;
} else if (this.dmUser.presence === 'offline') {
icon = Icon.PresenceOffline;
Expand Down
5 changes: 5 additions & 0 deletions src/components/views/rooms/PresenceLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export default class PresenceLabel extends React.Component<IProps> {
}

private getPrettyPresence(presence: string, activeAgo: number, currentlyActive: boolean): string {
// for busy presence, we ignore the 'currentlyActive' flag: they're busy whether
// they're active or not. It can be set while the user is active in which case
// the 'active ago' ends up being 0.
if (presence === "org.matrix.msc3026.busy") return _t("Busy");
dbkr marked this conversation as resolved.
Show resolved Hide resolved

if (!currentlyActive && activeAgo !== undefined && activeAgo > 0) {
const duration = this.getDuration(activeAgo);
if (presence === "online") return _t("Online for %(duration)s", { duration: duration });
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@
"%(duration)sm": "%(duration)sm",
"%(duration)sh": "%(duration)sh",
"%(duration)sd": "%(duration)sd",
"Busy": "Busy",
"Online for %(duration)s": "Online for %(duration)s",
"Idle for %(duration)s": "Idle for %(duration)s",
"Offline for %(duration)s": "Offline for %(duration)s",
Expand Down