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 { group } = pinnedThoughtGroup;
|
||||||
const firstThought = group.thoughts[0];
|
const firstThought = group.thoughts[0];
|
||||||
|
const pinnedCanBeLive = currentLeadSessionId
|
||||||
|
? firstThought.leadSessionId === currentLeadSessionId
|
||||||
|
: true;
|
||||||
const info = memberInfo.get(firstThought.from);
|
const info = memberInfo.get(firstThought.from);
|
||||||
const itemKey = getThoughtGroupKey(group);
|
const itemKey = getThoughtGroupKey(group);
|
||||||
const stableKey = itemKey;
|
const stableKey = itemKey;
|
||||||
|
|
@ -519,10 +522,10 @@ export const ActivityTimeline = React.memo(function ActivityTimeline({
|
||||||
key={itemKey}
|
key={itemKey}
|
||||||
group={group}
|
group={group}
|
||||||
memberColor={info?.color}
|
memberColor={info?.color}
|
||||||
canBeLive={true}
|
canBeLive={pinnedCanBeLive}
|
||||||
isTeamAlive={isTeamAlive}
|
isTeamAlive={pinnedCanBeLive ? isTeamAlive : undefined}
|
||||||
leadActivity={leadActivity}
|
leadActivity={pinnedCanBeLive ? leadActivity : undefined}
|
||||||
leadContextUpdatedAt={leadContextUpdatedAt}
|
leadContextUpdatedAt={pinnedCanBeLive ? leadContextUpdatedAt : undefined}
|
||||||
isNew={newItemKeys.has(itemKey)}
|
isNew={newItemKeys.has(itemKey)}
|
||||||
onVisible={onMessageVisible}
|
onVisible={onMessageVisible}
|
||||||
zebraShade={zebraShadeSet.has(0)}
|
zebraShade={zebraShadeSet.has(0)}
|
||||||
|
|
@ -591,9 +594,6 @@ export const ActivityTimeline = React.memo(function ActivityTimeline({
|
||||||
group={group}
|
group={group}
|
||||||
memberColor={info?.color}
|
memberColor={info?.color}
|
||||||
canBeLive={false}
|
canBeLive={false}
|
||||||
isTeamAlive={isTeamAlive}
|
|
||||||
leadActivity={leadActivity}
|
|
||||||
leadContextUpdatedAt={leadContextUpdatedAt}
|
|
||||||
isNew={newItemKeys.has(itemKey)}
|
isNew={newItemKeys.has(itemKey)}
|
||||||
onVisible={onMessageVisible}
|
onVisible={onMessageVisible}
|
||||||
zebraShade={zebraShadeSet.has(realIndex)}
|
zebraShade={zebraShadeSet.has(realIndex)}
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,27 @@ interface TeamMentionEntry {
|
||||||
deletedAt: string;
|
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 {
|
export interface TeamMentionMeta {
|
||||||
teamNames: string[];
|
teamNames: string[];
|
||||||
teamColorByName: ReadonlyMap<string, string>;
|
teamColorByName: ReadonlyMap<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTeamMentionEntries(teams: readonly TeamSummary[]): TeamMentionEntry[] {
|
function buildTeamMentionEntries(teams: readonly TeamSummary[]): TeamMentionEntry[] {
|
||||||
return teams.map((team) => ({
|
return teams
|
||||||
teamName: team.teamName ?? '',
|
.map((team) => ({
|
||||||
displayName: team.displayName ?? '',
|
teamName: team.teamName ?? '',
|
||||||
color: team.color ?? '',
|
displayName: team.displayName ?? '',
|
||||||
deletedAt: team.deletedAt ?? '',
|
color: team.color ?? '',
|
||||||
}));
|
deletedAt: team.deletedAt ?? '',
|
||||||
|
}))
|
||||||
|
.sort(compareTeamMentionEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
function areTeamMentionEntriesEqual(
|
function areTeamMentionEntriesEqual(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue