mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 03:10:38 +09:00
fix: suggest comment reassignment from recent commenter
This commit is contained in:
parent
ee85028534
commit
4ffa2b15dc
4 changed files with 71 additions and 20 deletions
|
|
@ -9,12 +9,40 @@ export interface AssigneeOption {
|
|||
searchText?: string;
|
||||
}
|
||||
|
||||
interface CommentAssigneeSuggestionInput {
|
||||
assigneeAgentId?: string | null;
|
||||
assigneeUserId?: string | null;
|
||||
}
|
||||
|
||||
interface CommentAssigneeSuggestionComment {
|
||||
authorAgentId?: string | null;
|
||||
authorUserId?: string | null;
|
||||
}
|
||||
|
||||
export function assigneeValueFromSelection(selection: Partial<AssigneeSelection>): string {
|
||||
if (selection.assigneeAgentId) return `agent:${selection.assigneeAgentId}`;
|
||||
if (selection.assigneeUserId) return `user:${selection.assigneeUserId}`;
|
||||
return "";
|
||||
}
|
||||
|
||||
export function suggestedCommentAssigneeValue(
|
||||
issue: CommentAssigneeSuggestionInput,
|
||||
comments: CommentAssigneeSuggestionComment[] | null | undefined,
|
||||
currentUserId: string | null | undefined,
|
||||
): string {
|
||||
if (comments && comments.length > 0 && currentUserId) {
|
||||
for (let i = comments.length - 1; i >= 0; i--) {
|
||||
const comment = comments[i];
|
||||
if (comment.authorAgentId) return assigneeValueFromSelection({ assigneeAgentId: comment.authorAgentId });
|
||||
if (comment.authorUserId && comment.authorUserId !== currentUserId) {
|
||||
return assigneeValueFromSelection({ assigneeUserId: comment.authorUserId });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return assigneeValueFromSelection(issue);
|
||||
}
|
||||
|
||||
export function parseAssigneeValue(value: string): AssigneeSelection {
|
||||
if (!value) {
|
||||
return { assigneeAgentId: null, assigneeUserId: null };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue