Ajout issue dans les commentaires
Signed-off-by: Gato <cedric@goutailler-olivier.fr>
This commit is contained in:
@@ -11,6 +11,7 @@ export type IssueComment = {
|
||||
text: string;
|
||||
createdAt: string;
|
||||
updatedAt: string | null;
|
||||
linkedIssueIds: number[];
|
||||
};
|
||||
|
||||
export type IssueEntity = {
|
||||
@@ -67,9 +68,17 @@ export class IssuesStore {
|
||||
this.data.update((issues) => [...issues, created]);
|
||||
return created;
|
||||
} else {
|
||||
const updated = this.normalizeIssue(
|
||||
await firstValueFrom(this.api.update(normalized.id, normalized)),
|
||||
);
|
||||
const apiResult = await firstValueFrom(this.api.update(normalized.id, normalized));
|
||||
// L'API ne retourne pas linkedIssueIds dans les commentaires : on le restaure
|
||||
// depuis les données envoyées pour ne pas perdre les liens.
|
||||
if (Array.isArray(apiResult.comments) && Array.isArray(normalized.comments)) {
|
||||
apiResult.comments = apiResult.comments.map((c: IssueComment) => {
|
||||
if (Array.isArray(c.linkedIssueIds)) return c;
|
||||
const sent = normalized.comments.find((nc) => nc.id === c.id);
|
||||
return { ...c, linkedIssueIds: sent?.linkedIssueIds ?? [] };
|
||||
});
|
||||
}
|
||||
const updated = this.normalizeIssue(apiResult);
|
||||
this.data.update((issues) => {
|
||||
const idx = issues.findIndex((i) => i.id === normalized.id);
|
||||
if (idx === -1) return issues;
|
||||
@@ -103,7 +112,12 @@ export class IssuesStore {
|
||||
type: issue.type ?? 'Story',
|
||||
estimatedTime: issue.estimatedTime ?? null,
|
||||
dependsOnIds: normalizedDependencies,
|
||||
comments: Array.isArray(issue.comments) ? issue.comments : [],
|
||||
comments: Array.isArray(issue.comments)
|
||||
? issue.comments.map((c) => ({
|
||||
...c,
|
||||
linkedIssueIds: Array.isArray(c.linkedIssueIds) ? c.linkedIssueIds : [],
|
||||
}))
|
||||
: [],
|
||||
} as IssueEntity;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user