add ability to set status and improve status appearance

This commit is contained in:
7w1 committed 2026-03-03 21:53:35 -06:00
1 parent 202495b466
commit 5b1bfa626d
7 files changed
+163 -29

No files matched your search

+10 -4
View File
@@ -44,6 +44,9 @@ export function UserHero({ userId, avatarUrl, bannerUrl, presence }: UserHeroPro
const coverUrl = cachedBannerUrl || cachedAvatarUrl;
const isFallbackCover = !cachedBannerUrl && !!cachedAvatarUrl;
const status = presence?.status;
const isExpandable = (status?.length ?? 0) > 70;
return (
<Box direction="Column" className={css.UserHero}>
<div
@@ -105,13 +108,16 @@ export function UserHero({ userId, avatarUrl, bannerUrl, presence }: UserHeroPro
</Overlay>
)}
</div>
{presence?.status?.length && (
{status && status.length > 0 && (
<div className={css.UserHeroStatusContainer}>
<Tooltip
onClick={() => setIsFullStatus(!isFullStatus)}
onClick={isExpandable ? () => setIsFullStatus(!isFullStatus) : undefined}
className={css.UserHeroStatusTooltip}
style={{
maxHeight: isFullStatus ? toRem(105) : toRem(48),
cursor: isExpandable ? 'pointer' : 'default',
transform: 'none',
transition: 'none',
}}
>
<Text
@@ -122,9 +128,9 @@ export function UserHero({ userId, avatarUrl, bannerUrl, presence }: UserHeroPro
wordBreak: 'break-word',
}}
>
{presence.status}
{status}
</Text>
{presence.status.length > 70 && (
{isExpandable && (
<Icon
size="50"
style={{ position: 'relative', left: '2.5%' }}
@@ -41,6 +41,7 @@ const KNOWN_KEYS = [
'moe.sable.app.bio',
'chat.commet.profile_bio',
'chat.commet.profile_banner',
'chat.commet.profile_status',
'io.fsky.nyx.pronouns',
'us.cloke.msc4175.tz',
'm.tz',
+36 -25
View File
@@ -25,6 +25,7 @@ import {
Tooltip,
TooltipProvider,
config,
toRem,
} from 'folds';
import { MatrixClient, Room, RoomMember } from '$types/matrix-sdk';
import { useVirtualizer } from '@tanstack/react-virtual';
@@ -101,16 +102,6 @@ function MemberDrawerHeader({ room }: MemberDrawerHeaderProps) {
</Header>
);
}
type MemberItemProps = {
mx: MatrixClient;
useAuthentication: boolean;
room: Room;
member: RoomMember;
onClick: MouseEventHandler<HTMLButtonElement>;
pressed?: boolean;
typing?: boolean;
};
function MemberItem({
mx,
useAuthentication,
@@ -125,9 +116,11 @@ function MemberItem({
getMemberDisplayName(room, member.userId, nicknames) ??
getMxIdLocalPart(member.userId) ??
member.userId;
// Increased the request size to 128x128 to maintain quality for the larger avatar
const avatarMxcUrl = member.getMxcAvatarUrl();
const avatarUrl = avatarMxcUrl
? mx.mxcUrlToHttp(avatarMxcUrl, 100, 100, 'crop', undefined, false, useAuthentication)
? mx.mxcUrlToHttp(avatarMxcUrl, 128, 128, 'crop', undefined, false, useAuthentication)
: undefined;
const presence = useUserPresence(member.userId);
@@ -142,18 +135,28 @@ function MemberItem({
radii="400"
onClick={onClick}
before={
<AvatarPresence
badge={presence && <PresenceBadge presence={presence.presence} size="200" />}
<div
style={{
position: 'relative',
width: toRem(40),
height: toRem(40),
transform: 'scale(0.85)',
transformOrigin: 'center',
}}
>
<Avatar size="200">
<UserAvatar
userId={member.userId}
src={avatarUrl ?? undefined}
alt={name}
renderFallback={() => <Icon size="50" src={Icons.User} filled />}
/>
</Avatar>
</AvatarPresence>
<AvatarPresence
badge={presence && <PresenceBadge presence={presence.presence} size="200" />}
>
<Avatar size="300" radii="400">
<UserAvatar
userId={member.userId}
src={avatarUrl ?? undefined}
alt={name}
renderFallback={() => <Icon size="100" src={Icons.User} filled />}
/>
</Avatar>
</AvatarPresence>
</div>
}
after={
typing && (
@@ -163,12 +166,20 @@ function MemberItem({
)
}
>
<Box direction="Column" grow="Yes">
<Text size="T400" truncate style={{ color, fontFamily: font }}>
<Box direction="Column" grow="Yes" gap="0">
<Text size="T300" truncate style={{ color, fontFamily: font, lineHeight: '1.2' }}>
{name}
</Text>
{presence?.status && (
<Text size="T300" truncate style={{ color: config.opacity.P300, fontFamily: font }}>
<Text
size="T200"
truncate
style={{
opacity: config.opacity.P300,
fontFamily: font,
marginTop: '-2px',
}}
>
{presence.status}
</Text>
)}
+1
View File
@@ -1075,6 +1075,7 @@ export function RoomTimeline({
delete cleanExtended['io.fsky.nyx.pronouns'];
delete cleanExtended['moe.sable.app.bio'];
delete cleanExtended['chat.commet.profile_bio'];
delete cleanExtended['chat.commet.profile_status'];
delete cleanExtended['us.cloke.msc4175.tz'];
delete cleanExtended['m.tz'];
delete cleanExtended['chat.commet.profile_banner'];
@@ -49,6 +49,8 @@ import { TimezoneEditor } from './TimezoneEditor';
import { PronounEditor } from './PronounEditor';
import { BioEditor } from './BioEditor';
import { NameColorEditor } from './NameColorEditor';
import { StatusEditor } from './StatusEditor';
import { useUserPresence } from '$hooks/useUserPresence';
type PronounSet = {
summary: string;
@@ -479,6 +481,8 @@ function ProfileExtended({ profile, userId }: ProfileProps) {
const setGlobalProfiles = useSetAtom(profilesCacheAtom);
const pronouns = (profile.pronouns as PronounSet[]) || [];
const presence = useUserPresence(userId);
const currentStatus = presence?.status || '';
// Unknown fields / unimplemented non-matrix-spec fields
// Only renders them, can't edit or set
@@ -496,9 +500,29 @@ function ProfileExtended({ profile, userId }: ProfileProps) {
[mx, userId, setGlobalProfiles]
);
const handleSaveStatus = useCallback(
async (newStatus: string) => {
const currentState = presence?.presence || 'online';
await mx.setPresence({
presence: currentState,
status_msg: newStatus,
});
},
[mx, presence]
);
return (
<Box direction="Column" gap="100">
<Text size="L400">Extended Profile</Text>
<SequenceCard
className={SequenceCardStyle}
variant="SurfaceVariant"
direction="Column"
gap="400"
>
<StatusEditor current={currentStatus} onSave={handleSaveStatus} />
</SequenceCard>
<SequenceCard
className={SequenceCardStyle}
variant="SurfaceVariant"
@@ -0,0 +1,88 @@
import { ChangeEventHandler, FormEventHandler, useEffect, useState } from 'react';
import { Box, Text, Button, Input, IconButton, Icon, Icons, Spinner } from 'folds';
import { SettingTile } from '$components/setting-tile';
import { config } from 'folds';
type StatusEditorProps = {
current?: string;
onSave: (status: string) => Promise<void>;
};
export function StatusEditor({ current = '', onSave }: StatusEditorProps) {
const [value, setValue] = useState(current);
const [saving, setSaving] = useState(false);
useEffect(() => {
setValue(current);
}, [current]);
const handleChange: ChangeEventHandler<HTMLInputElement> = (evt) => {
setValue(evt.currentTarget.value);
};
const handleReset = () => {
setValue(current);
};
const handleSubmit: FormEventHandler<HTMLFormElement> = async (evt) => {
evt.preventDefault();
if (saving) return;
if (value === current) return;
setSaving(true);
try {
await onSave(value);
} finally {
setSaving(false);
}
};
const hasChanges = value !== current;
return (
<SettingTile title="Status">
<Box direction="Column" grow="Yes" gap="100">
<Box as="form" onSubmit={handleSubmit} gap="200" aria-disabled={saving} grow="Yes">
<Box grow="Yes" direction="Column">
<Input
name="statusInput"
value={value}
onChange={handleChange}
placeholder="What's on your mind?"
variant="Secondary"
radii="300"
style={{ paddingRight: config.space.S200 }}
readOnly={saving}
after={
hasChanges &&
!saving && (
<IconButton
type="reset"
onClick={handleReset}
size="300"
radii="300"
variant="Secondary"
>
<Icon src={Icons.Cross} size="100" />
</IconButton>
)
}
/>
</Box>
<Button
size="400"
variant={hasChanges ? 'Success' : 'Secondary'}
fill={hasChanges ? 'Solid' : 'Soft'}
outlined
radii="300"
disabled={!hasChanges || saving}
type="submit"
>
{saving && <Spinner variant="Success" fill="Solid" size="300" />}
<Text size="B400">Save</Text>
</Button>
</Box>
</Box>
</SettingTile>
);
}
+3
View File
@@ -17,6 +17,7 @@ export type UserProfile = {
pronouns?: any[];
timezone?: string;
bio?: string;
status?: string;
bannerUrl?: string;
nameColor?: string;
extended?: Record<string, any>;
@@ -33,6 +34,7 @@ const normalizeInfo = (info: any): UserProfile => {
'moe.sable.app.bio',
'chat.commet.profile_bio',
'chat.commet.profile_banner',
'chat.commet.profile_status',
'moe.sable.app.name_color',
];
@@ -49,6 +51,7 @@ const normalizeInfo = (info: any): UserProfile => {
pronouns: info['io.fsky.nyx.pronouns'],
timezone: info['us.cloke.msc4175.tz'] || info['m.tz'],
bio: info['moe.sable.app.bio'] || info['chat.commet.profile_bio'],
status: info['chat.commet.profile_status'],
bannerUrl: info['chat.commet.profile_banner'],
nameColor: info['moe.sable.app.name_color'],
extended,