v0.12.33 text cleanup of the app and bug fixes.
This commit is contained in:
@@ -14,6 +14,55 @@ function nameToColor(name) {
|
||||
return AVATAR_COLORS[(name || '').charCodeAt(0) % AVATAR_COLORS.length];
|
||||
}
|
||||
|
||||
// Composite avatar layouts for the 40×40 chat header icon
|
||||
const COMPOSITE_LAYOUTS_SM = {
|
||||
1: [{ top: 4, left: 4, size: 32 }],
|
||||
2: [
|
||||
{ top: 10, left: 1, size: 19 },
|
||||
{ top: 10, right: 1, size: 19 },
|
||||
],
|
||||
3: [
|
||||
{ top: 2, left: 2, size: 17 },
|
||||
{ top: 2, right: 2, size: 17 },
|
||||
{ bottom: 2, left: 11, size: 17 },
|
||||
],
|
||||
4: [
|
||||
{ top: 1, left: 1, size: 18 },
|
||||
{ top: 1, right: 1, size: 18 },
|
||||
{ bottom: 1, left: 1, size: 18 },
|
||||
{ bottom: 1, right: 1, size: 18 },
|
||||
],
|
||||
};
|
||||
|
||||
function GroupAvatarCompositeSm({ memberPreviews }) {
|
||||
const members = (memberPreviews || []).slice(0, 4);
|
||||
const positions = COMPOSITE_LAYOUTS_SM[members.length];
|
||||
if (!positions) return null;
|
||||
return (
|
||||
<div className="group-icon-sm" style={{ background: '#1a1a2e', position: 'relative', padding: 0, overflow: 'hidden' }}>
|
||||
{members.map((m, i) => {
|
||||
const pos = positions[i];
|
||||
const base = {
|
||||
position: 'absolute',
|
||||
width: pos.size, height: pos.size,
|
||||
borderRadius: '50%',
|
||||
...(pos.top !== undefined ? { top: pos.top } : {}),
|
||||
...(pos.bottom !== undefined ? { bottom: pos.bottom } : {}),
|
||||
...(pos.left !== undefined ? { left: pos.left } : {}),
|
||||
...(pos.right !== undefined ? { right: pos.right } : {}),
|
||||
overflow: 'hidden', flexShrink: 0,
|
||||
};
|
||||
if (m.avatar) return <img key={m.id} src={m.avatar} alt={m.name} style={{ ...base, objectFit: 'cover' }} />;
|
||||
return (
|
||||
<div key={m.id} style={{ ...base, background: nameToColor(m.name), display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: Math.round(pos.size * 0.42), fontWeight: 700, color: 'white' }}>
|
||||
{(m.name || '')[0]?.toUpperCase()}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function ChatWindow({ group, onBack, onGroupUpdated, onDirectMessage, onMessageDeleted, onHasTextChange, onlineUserIds = new Set() }) {
|
||||
const { user: currentUser } = useAuth();
|
||||
const { socket } = useSocket();
|
||||
@@ -267,6 +316,8 @@ export default function ChatWindow({ group, onBack, onGroupUpdated, onDirectMess
|
||||
<div className="group-icon-sm" style={{ background: avatarColors.dm, borderRadius: 8, flexShrink: 0, fontSize: 11, fontWeight: 700 }}>
|
||||
{group.is_multi_group ? 'MG' : 'UG'}
|
||||
</div>
|
||||
) : group.composite_members?.length > 0 ? (
|
||||
<GroupAvatarCompositeSm memberPreviews={group.composite_members} />
|
||||
) : (
|
||||
<div className="group-icon-sm" style={{ background: group.type === 'public' ? avatarColors.public : avatarColors.dm, flexShrink: 0 }}>
|
||||
{group.type === 'public' ? '#' : group.name[0]?.toUpperCase()}
|
||||
|
||||
Reference in New Issue
Block a user