forked from github/plane
fix: project empty state flicker (#4609)
This commit is contained in:
parent
6825f8a386
commit
a8fcaf1f48
@ -16,9 +16,11 @@ export const ProjectCardList = observer(() => {
|
|||||||
// store hooks
|
// store hooks
|
||||||
const { toggleCreateProjectModal } = useCommandPalette();
|
const { toggleCreateProjectModal } = useCommandPalette();
|
||||||
const { setTrackElement } = useEventTracker();
|
const { setTrackElement } = useEventTracker();
|
||||||
const { workspaceProjectIds, filteredProjectIds, getProjectById } = useProject();
|
const { workspaceProjectIds, filteredProjectIds, getProjectById, loader } = useProject();
|
||||||
const { searchQuery, currentWorkspaceDisplayFilters } = useProjectFilter();
|
const { searchQuery, currentWorkspaceDisplayFilters } = useProjectFilter();
|
||||||
|
|
||||||
|
if (!filteredProjectIds || !workspaceProjectIds || loader) return <ProjectsLoader />;
|
||||||
|
|
||||||
if (workspaceProjectIds?.length === 0 && !currentWorkspaceDisplayFilters?.archived_projects)
|
if (workspaceProjectIds?.length === 0 && !currentWorkspaceDisplayFilters?.archived_projects)
|
||||||
return (
|
return (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
@ -30,8 +32,6 @@ export const ProjectCardList = observer(() => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!filteredProjectIds) return <ProjectsLoader />;
|
|
||||||
|
|
||||||
if (filteredProjectIds.length === 0)
|
if (filteredProjectIds.length === 0)
|
||||||
return (
|
return (
|
||||||
<div className="grid h-full w-full place-items-center">
|
<div className="grid h-full w-full place-items-center">
|
||||||
|
@ -14,6 +14,7 @@ import { RootStore } from "../root.store";
|
|||||||
|
|
||||||
export interface IProjectStore {
|
export interface IProjectStore {
|
||||||
// observables
|
// observables
|
||||||
|
loader: boolean;
|
||||||
projectMap: {
|
projectMap: {
|
||||||
[projectId: string]: IProject; // projectId: project Info
|
[projectId: string]: IProject; // projectId: project Info
|
||||||
};
|
};
|
||||||
@ -47,6 +48,7 @@ export interface IProjectStore {
|
|||||||
|
|
||||||
export class ProjectStore implements IProjectStore {
|
export class ProjectStore implements IProjectStore {
|
||||||
// observables
|
// observables
|
||||||
|
loader: boolean = false;
|
||||||
projectMap: {
|
projectMap: {
|
||||||
[projectId: string]: IProject; // projectId: project Info
|
[projectId: string]: IProject; // projectId: project Info
|
||||||
} = {};
|
} = {};
|
||||||
@ -62,6 +64,7 @@ export class ProjectStore implements IProjectStore {
|
|||||||
constructor(_rootStore: RootStore) {
|
constructor(_rootStore: RootStore) {
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
// observables
|
// observables
|
||||||
|
loader: observable.ref,
|
||||||
projectMap: observable,
|
projectMap: observable,
|
||||||
// computed
|
// computed
|
||||||
filteredProjectIds: computed,
|
filteredProjectIds: computed,
|
||||||
@ -208,15 +211,18 @@ export class ProjectStore implements IProjectStore {
|
|||||||
*/
|
*/
|
||||||
fetchProjects = async (workspaceSlug: string) => {
|
fetchProjects = async (workspaceSlug: string) => {
|
||||||
try {
|
try {
|
||||||
|
this.loader = true;
|
||||||
const projectsResponse = await this.projectService.getProjects(workspaceSlug);
|
const projectsResponse = await this.projectService.getProjects(workspaceSlug);
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
projectsResponse.forEach((project) => {
|
projectsResponse.forEach((project) => {
|
||||||
set(this.projectMap, [project.id], project);
|
set(this.projectMap, [project.id], project);
|
||||||
});
|
});
|
||||||
|
this.loader = false;
|
||||||
});
|
});
|
||||||
return projectsResponse;
|
return projectsResponse;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Failed to fetch project from workspace store");
|
console.log("Failed to fetch project from workspace store");
|
||||||
|
this.loader = false;
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user