Ajoute projet et migration milestone
Signed-off-by: Gato <cedric@goutailler-olivier.fr>
This commit is contained in:
@@ -37,6 +37,7 @@ export type IssueEntity = {
|
||||
export class IssuesStore {
|
||||
private readonly api = inject(IssuesApiService);
|
||||
private readonly data = signal<IssueEntity[]>([]);
|
||||
private currentProjectId: number | null = null;
|
||||
|
||||
readonly loading = signal(false);
|
||||
readonly loaded = signal(false);
|
||||
@@ -51,11 +52,13 @@ export class IssuesStore {
|
||||
return ids.length === 0 ? 1 : Math.max(...ids) + 1;
|
||||
}
|
||||
|
||||
async load(): Promise<void> {
|
||||
if (this.loaded()) return;
|
||||
async load(projectId: number): Promise<void> {
|
||||
if (this.loaded() && this.currentProjectId === projectId) return;
|
||||
this.currentProjectId = projectId;
|
||||
this.loaded.set(false);
|
||||
this.loading.set(true);
|
||||
try {
|
||||
const issues = await firstValueFrom(this.api.getAll());
|
||||
const issues = await firstValueFrom(this.api.getAll(projectId));
|
||||
this.data.set(issues.map((i) => this.normalizeIssue(i)));
|
||||
this.loaded.set(true);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user