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

Commit 23d5ba9

Browse files
authored
Support MSC3026 busy presence (#8043)
* Support MSC3026 busy presence * Use UnstableValue * Add the import
1 parent afadea0 commit 23d5ba9

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

res/css/views/avatars/_DecoratedRoomAvatar.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ limitations under the License.
6565
background-color: $presence-away;
6666
}
6767

68+
.mx_DecoratedRoomAvatar_icon_busy::before {
69+
background-color: $presence-busy;
70+
}
71+
6872
.mx_NotificationBadge, .mx_RoomTile_badgeContainer {
6973
position: absolute;
7074
top: 0;

res/themes/legacy-light/css/_legacy-light.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ $roomtile-selected-bg-color: #fff;
137137

138138
$presence-away: #d9b072;
139139
$presence-offline: #e3e8f0;
140+
$presence-busy: #FF5B55;
140141

141142
// Legacy theme backports
142143
$accent: #0DBD8B;

res/themes/light/css/_light.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ $rte-code-bg-color: rgba(0, 0, 0, 0.04);
136136
// ********************
137137
$presence-away: #d9b072;
138138
$presence-offline: $quinary-content;
139+
$presence-busy: $alert;
139140
// ********************
140141

141142
// Inputs

src/components/views/avatars/DecoratedRoomAvatar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { User, UserEvent } from "matrix-js-sdk/src/models/user";
2121
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
2222
import { EventType } from "matrix-js-sdk/src/@types/event";
2323
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
24+
import { UnstableValue } from "matrix-js-sdk/src/NamespacedValue";
2425

2526
import RoomAvatar from "./RoomAvatar";
2627
import NotificationBadge from '../rooms/NotificationBadge';
@@ -50,13 +51,16 @@ interface IState {
5051
icon: Icon;
5152
}
5253

54+
const BUSY_PRESENCE_NAME = new UnstableValue("busy", "org.matrix.msc3026.busy");
55+
5356
enum Icon {
5457
// Note: the names here are used in CSS class names
5558
None = "NONE", // ... except this one
5659
Globe = "GLOBE",
5760
PresenceOnline = "ONLINE",
5861
PresenceAway = "AWAY",
5962
PresenceOffline = "OFFLINE",
63+
PresenceBusy = "BUSY",
6064
}
6165

6266
function tooltipText(variant: Icon) {
@@ -69,6 +73,8 @@ function tooltipText(variant: Icon) {
6973
return _t("Away");
7074
case Icon.PresenceOffline:
7175
return _t("Offline");
76+
case Icon.PresenceBusy:
77+
return _t("Busy");
7278
}
7379
}
7480

@@ -141,7 +147,9 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
141147
let icon = Icon.None;
142148

143149
const isOnline = this.dmUser.currentlyActive || this.dmUser.presence === 'online';
144-
if (isOnline) {
150+
if (BUSY_PRESENCE_NAME.matches(this.dmUser.presence)) {
151+
icon = Icon.PresenceBusy;
152+
} else if (isOnline) {
145153
icon = Icon.PresenceOnline;
146154
} else if (this.dmUser.presence === 'offline') {
147155
icon = Icon.PresenceOffline;

src/components/views/rooms/PresenceLabel.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ limitations under the License.
1515
*/
1616

1717
import React from 'react';
18+
import { UnstableValue } from "matrix-js-sdk/src/NamespacedValue";
1819

1920
import { _t } from '../../../languageHandler';
2021
import { replaceableComponent } from "../../../utils/replaceableComponent";
2122

23+
const BUSY_PRESENCE_NAME = new UnstableValue("busy", "org.matrix.msc3026.busy");
24+
2225
interface IProps {
2326
// number of milliseconds ago this user was last active.
2427
// zero = unknown
@@ -62,6 +65,11 @@ export default class PresenceLabel extends React.Component<IProps> {
6265
}
6366

6467
private getPrettyPresence(presence: string, activeAgo: number, currentlyActive: boolean): string {
68+
// for busy presence, we ignore the 'currentlyActive' flag: they're busy whether
69+
// they're active or not. It can be set while the user is active in which case
70+
// the 'active ago' ends up being 0.
71+
if (BUSY_PRESENCE_NAME.matches(presence)) return _t("Busy");
72+
6573
if (!currentlyActive && activeAgo !== undefined && activeAgo > 0) {
6674
const duration = this.getDuration(activeAgo);
6775
if (presence === "online") return _t("Online for %(duration)s", { duration: duration });

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,7 @@
17401740
"%(duration)sm": "%(duration)sm",
17411741
"%(duration)sh": "%(duration)sh",
17421742
"%(duration)sd": "%(duration)sd",
1743+
"Busy": "Busy",
17431744
"Online for %(duration)s": "Online for %(duration)s",
17441745
"Idle for %(duration)s": "Idle for %(duration)s",
17451746
"Offline for %(duration)s": "Offline for %(duration)s",

0 commit comments

Comments
 (0)