refactor: improve ActivityTimeline and team mention entry sorting
- Updated ActivityTimeline to conditionally set `canBeLive`, `isTeamAlive`, `leadActivity`, and `leadContextUpdatedAt` based on the current lead session. - Enhanced sorting of team mention entries in useStableTeamMentionMeta by introducing a comparison function for better organization of team data.
This commit is contained in:
parent
038c3f8bb4
commit
ccc3f55243
2 changed files with 22 additions and 13 deletions
|
|
@ -510,6 +510,9 @@ export const ActivityTimeline = React.memo(function ActivityTimeline({
|
|||
(() => {
|
||||
const { group } = pinnedThoughtGroup;
|
||||
const firstThought = group.thoughts[0];
|
||||
const pinnedCanBeLive = currentLeadSessionId
|
||||
? firstThought.leadSessionId === currentLeadSessionId
|
||||
: true;
|
||||
const info = memberInfo.get(firstThought.from);
|
||||
const itemKey = getThoughtGroupKey(group);
|
||||
const stableKey = itemKey;
|
||||
|
|
@ -519,10 +522,10 @@ export const ActivityTimeline = React.memo(function ActivityTimeline({
|
|||
key={itemKey}
|
||||
group={group}
|
||||
memberColor={info?.color}
|
||||
canBeLive={true}
|
||||
isTeamAlive={isTeamAlive}
|
||||
leadActivity={leadActivity}
|
||||
leadContextUpdatedAt={leadContextUpdatedAt}
|
||||
canBeLive={pinnedCanBeLive}
|
||||
isTeamAlive={pinnedCanBeLive ? isTeamAlive : undefined}
|
||||
leadActivity={pinnedCanBeLive ? leadActivity : undefined}
|
||||
leadContextUpdatedAt={pinnedCanBeLive ? leadContextUpdatedAt : undefined}
|
||||
isNew={newItemKeys.has(itemKey)}
|
||||
onVisible={onMessageVisible}
|
||||
zebraShade={zebraShadeSet.has(0)}
|
||||
|
|
@ -591,9 +594,6 @@ export const ActivityTimeline = React.memo(function ActivityTimeline({
|
|||
group={group}
|
||||
memberColor={info?.color}
|
||||
canBeLive={false}
|
||||
isTeamAlive={isTeamAlive}
|
||||
leadActivity={leadActivity}
|
||||
leadContextUpdatedAt={leadContextUpdatedAt}
|
||||
isNew={newItemKeys.has(itemKey)}
|
||||
onVisible={onMessageVisible}
|
||||
zebraShade={zebraShadeSet.has(realIndex)}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,27 @@ interface TeamMentionEntry {
|
|||
deletedAt: string;
|
||||
}
|
||||
|
||||
function compareTeamMentionEntries(a: TeamMentionEntry, b: TeamMentionEntry): number {
|
||||
return (
|
||||
a.teamName.localeCompare(b.teamName, undefined, { sensitivity: 'base' }) ||
|
||||
a.displayName.localeCompare(b.displayName, undefined, { sensitivity: 'base' })
|
||||
);
|
||||
}
|
||||
|
||||
export interface TeamMentionMeta {
|
||||
teamNames: string[];
|
||||
teamColorByName: ReadonlyMap<string, string>;
|
||||
}
|
||||
|
||||
function buildTeamMentionEntries(teams: readonly TeamSummary[]): TeamMentionEntry[] {
|
||||
return teams.map((team) => ({
|
||||
teamName: team.teamName ?? '',
|
||||
displayName: team.displayName ?? '',
|
||||
color: team.color ?? '',
|
||||
deletedAt: team.deletedAt ?? '',
|
||||
}));
|
||||
return teams
|
||||
.map((team) => ({
|
||||
teamName: team.teamName ?? '',
|
||||
displayName: team.displayName ?? '',
|
||||
color: team.color ?? '',
|
||||
deletedAt: team.deletedAt ?? '',
|
||||
}))
|
||||
.sort(compareTeamMentionEntries);
|
||||
}
|
||||
|
||||
function areTeamMentionEntriesEqual(
|
||||
|
|
|
|||
Loading…
Reference in a new issue