From 5b1bfa626d05168eecdaee9c63fbd180d8bbc91d Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 3 Mar 2026 21:53:35 -0600 Subject: [PATCH] add ability to set status and improve status appearance --- src/app/components/user-profile/UserHero.tsx | 14 ++- .../user-profile/UserRoomProfile.tsx | 1 + src/app/features/room/MembersDrawer.tsx | 61 +++++++------ src/app/features/room/RoomTimeline.tsx | 1 + src/app/features/settings/account/Profile.tsx | 24 +++++ .../settings/account/StatusEditor.tsx | 88 +++++++++++++++++++ src/app/hooks/useUserProfile.ts | 3 + 7 files changed, 163 insertions(+), 29 deletions(-) create mode 100644 src/app/features/settings/account/StatusEditor.tsx diff --git a/src/app/components/user-profile/UserHero.tsx b/src/app/components/user-profile/UserHero.tsx index 1b9130803..3c1cbeb29 100644 --- a/src/app/components/user-profile/UserHero.tsx +++ b/src/app/components/user-profile/UserHero.tsx @@ -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 (
)}
- {presence?.status?.length && ( + {status && status.length > 0 && (
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', }} > - {presence.status} + {status} - {presence.status.length > 70 && ( + {isExpandable && ( ); } - -type MemberItemProps = { - mx: MatrixClient; - useAuthentication: boolean; - room: Room; - member: RoomMember; - onClick: MouseEventHandler; - 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={ - } +
- - } - /> - - + } + > + + } + /> + + +
} after={ typing && ( @@ -163,12 +166,20 @@ function MemberItem({ ) } > - - + + {name} {presence?.status && ( - + {presence.status} )} diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 96d8c769f..c153ab524 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -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']; diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx index 06caf8411..d79d72782 100644 --- a/src/app/features/settings/account/Profile.tsx +++ b/src/app/features/settings/account/Profile.tsx @@ -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 ( Extended Profile + + + Promise; +}; + +export function StatusEditor({ current = '', onSave }: StatusEditorProps) { + const [value, setValue] = useState(current); + const [saving, setSaving] = useState(false); + useEffect(() => { + setValue(current); + }, [current]); + + const handleChange: ChangeEventHandler = (evt) => { + setValue(evt.currentTarget.value); + }; + + const handleReset = () => { + setValue(current); + }; + + const handleSubmit: FormEventHandler = 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 ( + + + + + + + + ) + } + /> + + + + + + ); +} diff --git a/src/app/hooks/useUserProfile.ts b/src/app/hooks/useUserProfile.ts index 439d3a68d..53dccdd4c 100644 --- a/src/app/hooks/useUserProfile.ts +++ b/src/app/hooks/useUserProfile.ts @@ -17,6 +17,7 @@ export type UserProfile = { pronouns?: any[]; timezone?: string; bio?: string; + status?: string; bannerUrl?: string; nameColor?: string; extended?: Record; @@ -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,