Skip to content

Commit e3e5e05

Browse files
Copilotalexr00
andcommitted
Handle self-assignment in mixed assignment/unassignment events
Also apply special wording for self-assignment when both assignments and unassignments occur in the same consolidated event. Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 71cf3f0 commit e3e5e05

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

webviews/components/timeline.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,20 +456,21 @@ const AssignUnassignEventView = ({ event }: { event: AssignEvent | UnassignEvent
456456
const { actor } = event;
457457
const assignees = (event as AssignEvent).assignees || [];
458458
const unassignees = (event as UnassignEvent).unassignees || [];
459-
const joinedAssignees = joinWithAnd(assignees.map(a => <AuthorLink key={`${a.id}a`} for={a} />));
460-
const joinedUnassignees = joinWithAnd(unassignees.map(a => <AuthorLink key={`${a.id}u`} for={a} />));
461-
459+
462460
// Check if actor is assigning/unassigning themselves
463461
const isSelfAssign = assignees.length === 1 && assignees[0].login === actor.login;
464462
const isSelfUnassign = unassignees.length === 1 && unassignees[0].login === actor.login;
465463

466464
let message: JSX.Element;
467465
if (assignees.length > 0 && unassignees.length > 0) {
468-
message = <>assigned {joinedAssignees} and unassigned {joinedUnassignees}</>;
466+
// Handle mixed case with potential self-assignment
467+
const assignMessage = isSelfAssign ? <>assigned themselves</> : <>assigned {joinWithAnd(assignees.map(a => <AuthorLink key={`${a.id}a`} for={a} />))}</>;
468+
const unassignMessage = isSelfUnassign ? <>removed their assignment</> : <>unassigned {joinWithAnd(unassignees.map(a => <AuthorLink key={`${a.id}u`} for={a} />))}</>;
469+
message = <>{assignMessage} and {unassignMessage}</>;
469470
} else if (assignees.length > 0) {
470-
message = isSelfAssign ? <>assigned themselves</> : <>assigned {joinedAssignees}</>;
471+
message = isSelfAssign ? <>assigned themselves</> : <>assigned {joinWithAnd(assignees.map(a => <AuthorLink key={`${a.id}a`} for={a} />))}</>;
471472
} else {
472-
message = isSelfUnassign ? <>removed their assignment</> : <>unassigned {joinedUnassignees}</>;
473+
message = isSelfUnassign ? <>removed their assignment</> : <>unassigned {joinWithAnd(unassignees.map(a => <AuthorLink key={`${a.id}u`} for={a} />))}</>;
473474
}
474475

475476
return (

0 commit comments

Comments
 (0)