{loadError ? '群组信息加载失败' : '加载中…'}
diff --git a/src/views/group-management-view.jsx b/src/views/group-management-view.jsx index 950c7d69..d4f5c063 100644 --- a/src/views/group-management-view.jsx +++ b/src/views/group-management-view.jsx @@ -393,28 +393,44 @@ function GroupSettings({topic, myUserId, tinode, onToast}) { ; } -function GroupProfile({topic, onToast}) { +function GroupProfile({topic, myUserId, onToast}) { // Shares 'group:'+topic with the nickname/description editors' own getGroup(topic) calls -- opening // this once warms the cache for either of those too. const [group, setGroup] = React.useState(() => (topic && readCachedData('group:' + topic)) || null); const [loadError, setLoadError] = React.useState(false); + // "群昵称" here means "my nickname within this group" (see MyNicknameEditor below), not the group's + // own name -- confirmed live this preview row was showing group.name instead, since it's easy to + // conflate the two. Reuses the same getGroupMembers+filter approach MyNicknameEditor already uses + // (there's no working "me" shortcut on the member-profile-by-id endpoint to fetch this more directly). + const [myNickname, setMyNickname] = React.useState(''); React.useEffect(() => { if (!topic) return; setGroup(readCachedData('group:' + topic) || null); getGroup(topic).then(g => { writeCachedData('group:' + topic, g); setGroup(g); }).catch(() => { onToast('加载失败'); setLoadError(true); }); }, [topic]); + React.useEffect(() => { + if (!topic || !myUserId) return; + getGroupMembers(topic, {query: ''}).then(data => { + const me = (data.items || []).find(m => m.user_id === myUserId); + if (me) setMyNickname(me.group_nickname || ''); + }).catch(() => {}); + }, [topic, myUserId]); if (!group) return
{loadError ? '群组信息加载失败' : '加载中…'}