Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/bundled/channels/ChannelSidebarItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { ChannelSidebarItem } from "./ChannelSidebarItem";

afterEach(cleanup);

const noTyping = Object.freeze([]);

function owner(profiles = new Map<string, Profile>()) {
const listeners = new Set<() => void>();
let snapshot: UnreadSnapshot = {
Expand All @@ -40,6 +42,7 @@ function owner(profiles = new Map<string, Profile>()) {
snapshot: () => profiles,
subscribe: () => () => {},
},
typing: { snapshot: () => noTyping, subscribe: () => () => {} },
unread: {
snapshot: () => snapshot,
subscribe: (_target: unknown, listener: () => void) => {
Expand Down
58 changes: 32 additions & 26 deletions src/bundled/channels/ChannelSidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ChatCircleIcon } from "../../shared/design-system/icons/index";
import { channelIcon } from "../../features/channels/channel-icon";
import { ChannelActivityPopover } from "./ChannelActivityPopover";
import { ChannelSidebarRow } from "./ChannelSidebarRow";
import { DmTypingBadge } from "./DmTypingBadge";
import { usePresenceStatus } from "../../features/presence/react";
import { UnreadBadge } from "./UnreadBadge";
import styles from "./Channels.module.css";
Expand Down Expand Up @@ -91,32 +92,37 @@ export const ChannelSidebarItem = memo(function ChannelSidebarItem({
channel={channel}
dmVisualSpacing={channel.channelType === "dm"}
icon={
channel.channelType === "dm" && channel.participants?.length === 1 ? (
<span className={styles.dmAvatar} data-dm-identity="">
<Avatar
src={
profile?.picture
? session.media(profile.picture, "small")
: undefined
}
alt=""
fallback={channel.name}
size="fill"
shape={profile?.isAgent ? "squircle" : "circle"}
statusBadge={presence === "unknown" ? undefined : presence}
/>
</span>
) : channel.channelType === "dm" &&
(channel.participants?.length ?? 0) > 1 ? (
<span
className={styles.dmCount}
data-dm-identity=""
data-dm-participant-count=""
title={`${channel.participants?.length} other participants`}
aria-hidden="true"
>
{channel.participants?.length}
</span>
channel.channelType === "dm" ? (
<DmTypingBadge session={session} channelId={channel.id}>
{channel.participants?.length === 1 ? (
<span className={styles.dmAvatar} data-dm-identity="">
<Avatar
src={
profile?.picture
? session.media(profile.picture, "small")
: undefined
}
alt=""
fallback={channel.name}
size="fill"
shape={profile?.isAgent ? "squircle" : "circle"}
statusBadge={presence === "unknown" ? undefined : presence}
/>
</span>
) : (channel.participants?.length ?? 0) > 1 ? (
<span
className={styles.dmCount}
data-dm-identity=""
data-dm-participant-count=""
title={`${channel.participants?.length} other participants`}
aria-hidden="true"
>
{channel.participants?.length}
</span>
) : (
<Icon size={16} />
)}
</DmTypingBadge>
) : (
<Icon size={16} />
)
Expand Down
36 changes: 36 additions & 0 deletions src/bundled/channels/Channels.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,42 @@
background: var(--affordance-accent-prominent);
}

/* Occupies the DM identity box while it replaces the avatar or count; shares
the participant-count chip's subtle roles. */
.typing {
display: inline-flex;
width: 22px;
height: 22px;
flex: 0 0 22px;
align-items: center;
justify-content: center;
gap: var(--space-half);
border-radius: var(--radius-pill);
background: var(--affordance-subtle);
}
.typing > span {
width: 4px;
height: 4px;
border-radius: 50%;
background: var(--text-subtle);
}
@keyframes typing-pulse {
50% {
opacity: 0.35;
}
}
@media (prefers-reduced-motion: no-preference) {
.typing > span {
animation: typing-pulse 1.4s ease-in-out infinite;
}
.typing > span:nth-child(2) {
animation-delay: 0.2s;
}
.typing > span:nth-child(3) {
animation-delay: 0.4s;
}
}

/* Match the adjacent small avatars without creating image/profile demand. */
.dmAvatar {
display: inline-grid;
Expand Down
Loading
Loading