improvement: update fetch map during workspace-level module fetch to reduce redundant API calls (#6159)
This commit is contained in:
parent
6cd8af1092
commit
aa1e192a50
1 changed files with 6 additions and 1 deletions
|
|
@ -39,7 +39,7 @@ export interface IModuleStore {
|
||||||
updateModuleDistribution: (distributionUpdates: DistributionUpdates, moduleId: string) => void;
|
updateModuleDistribution: (distributionUpdates: DistributionUpdates, moduleId: string) => void;
|
||||||
fetchWorkspaceModules: (workspaceSlug: string) => Promise<IModule[]>;
|
fetchWorkspaceModules: (workspaceSlug: string) => Promise<IModule[]>;
|
||||||
fetchModules: (workspaceSlug: string, projectId: string) => Promise<undefined | IModule[]>;
|
fetchModules: (workspaceSlug: string, projectId: string) => Promise<undefined | IModule[]>;
|
||||||
fetchModulesSlim: (workspaceSlug: string, projectId: string) => Promise<undefined | IModule[]>
|
fetchModulesSlim: (workspaceSlug: string, projectId: string) => Promise<undefined | IModule[]>;
|
||||||
fetchArchivedModules: (workspaceSlug: string, projectId: string) => Promise<undefined | IModule[]>;
|
fetchArchivedModules: (workspaceSlug: string, projectId: string) => Promise<undefined | IModule[]>;
|
||||||
fetchArchivedModuleDetails: (workspaceSlug: string, projectId: string, moduleId: string) => Promise<IModule>;
|
fetchArchivedModuleDetails: (workspaceSlug: string, projectId: string, moduleId: string) => Promise<IModule>;
|
||||||
fetchModuleDetails: (workspaceSlug: string, projectId: string, moduleId: string) => Promise<IModule>;
|
fetchModuleDetails: (workspaceSlug: string, projectId: string, moduleId: string) => Promise<IModule>;
|
||||||
|
|
@ -253,6 +253,11 @@ export class ModulesStore implements IModuleStore {
|
||||||
response.forEach((module) => {
|
response.forEach((module) => {
|
||||||
set(this.moduleMap, [module.id], { ...this.moduleMap[module.id], ...module });
|
set(this.moduleMap, [module.id], { ...this.moduleMap[module.id], ...module });
|
||||||
});
|
});
|
||||||
|
// check for all unique project ids and update the fetchedMap
|
||||||
|
const uniqueProjectIds = new Set(response.map((module) => module.project_id));
|
||||||
|
uniqueProjectIds.forEach((projectId) => {
|
||||||
|
set(this.fetchedMap, projectId, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue