From e4c6e1b246003bf5d91593f3d42d94e4e57d6cb6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 3 Sep 2026 17:08:38 +0800 Subject: [PATCH] Fix group-profile nickname preview showing group name instead of my own nickname MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GroupProfile's "群昵称" preview row showed group.name -- the group's own display name -- instead of the current user's personal nickname within that group (a real, distinct concept, correctly handled by the existing MyNicknameEditor/group-my-nickname page, just not wired into this preview row). Ported the substance of a bug dev independently found and fixed in their own reimplementation of this same page ("show saved group nickname", found while evaluating what from dev's post-fork commits was worth bringing over). Reuses the same getGroupMembers+filter-by-myUserId approach MyNicknameEditor already uses in this file (there's no working "me" shortcut on the member-profile-by-id endpoint that would let this be fetched more directly -- confirmed by reading server/im_http.go's routing, which never special-cases that literal string). Also renamed the adjacent "群昵称"->"群名称" label for the group's own display name field, since having two rows both labeled "群昵称" (one for my personal nickname, one for the group's name) is exactly the confusion that caused this bug in the first place. Evaluated the rest of dev's post-fork commits (9 commits fixing this same page's nickname-save reliability, plus the wholesale chapter-view reimplementation) for anything else worth porting: the version-conflict retry logic they built doesn't apply here since this branch already sends version:0 (confirmed server/im_http.go:4793 treats <=0 as "skip the check" -- the exact mechanism their fix was working around a different way), and their nickname maxLength bump (11->20) is already exceeded by this branch's existing 32, which matches the real backend limit (server/im_http.go:4789). Nothing else from dev's branch was found applicable. Co-Authored-By: Claude Sonnet 5 --- src/views/group-management-view.jsx | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) 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 = ;