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 ? '群组信息加载失败' : '加载中…'}

; const canEdit = group.permissions && group.permissions.can_edit_profile; + const nicknameLabel = myNickname || '未设置'; return
+ {canEdit ? : -
群昵称{group.name}
} +
群名称{group.name}
} {canEdit ? : @@ -425,7 +441,7 @@ function GroupProfile({topic, onToast}) {
; } -function AvatarSheet({topic, tinode, onToast}) { +function AvatarSheet({topic, myUserId, tinode, onToast}) { const inputRef = React.useRef(null); const [uploading, setUploading] = React.useState(false); const pick = () => inputRef.current && inputRef.current.click(); @@ -897,8 +913,8 @@ export default function GroupManagementView({view, hashParams, myUserId, tinode, else if (view === 'group-join-requests') content = ; else if (view === 'group-announcement-detail') content = ; else if (view === 'group-settings') content = ; - else if (view === 'group-profile') content = ; - else if (view === 'group-avatar') content = ; + else if (view === 'group-profile') content = ; + else if (view === 'group-avatar') content = ; else if (view === 'group-nickname') content = ; else if (view === 'group-description') content = ; else if (view === 'group-my-nickname') content = ;