Skip to content

Commit

Permalink
Fix double progress while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Aug 20, 2024
1 parent 2ec66ee commit 2bb14b9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions examples/crm/src/companies/CompanyList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import {
TopToolbar,
ExportButton,
Expand All @@ -13,7 +12,7 @@ import {

import { ImageList } from './GridList';
import { CompanyListFilter } from './CompanyListFilter';
import { LinearProgress, Stack } from '@mui/material';
import { Stack } from '@mui/material';
import { CompanyEmpty } from './CompanyEmpty';

export const CompanyList = () => {
Expand All @@ -30,7 +29,7 @@ const CompanyListLayout = () => {
const { data, isPending, filterValues } = useListContext();
const hasFilters = filterValues && Object.keys(filterValues).length > 0;

if (isPending) return <LinearProgress />;
if (isPending) return null;
if (!data?.length && !hasFilters) return <CompanyEmpty />;

return (
Expand Down
6 changes: 3 additions & 3 deletions examples/crm/src/contacts/ContactList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-anonymous-default-export */
import { Card, LinearProgress, Stack } from '@mui/material';
import { Card, Stack } from '@mui/material';
import jsonExport from 'jsonexport/dist';
import type { Exporter, Identifier, RaRecord } from 'react-admin';
import {
Expand All @@ -17,6 +17,7 @@ import {
useGetIdentity,
useListContext,
} from 'react-admin';

import { Company, Contact, Sale, Tag } from '../types';
import { ContactEmpty } from './ContactEmpty';
import { ContactImportButton } from './ContactImportButton';
Expand Down Expand Up @@ -45,8 +46,7 @@ const ContactListLayout = () => {

const hasFilters = filterValues && Object.keys(filterValues).length > 0;

if (!identity) return null;
if (isPending) return <LinearProgress />;
if (!identity || isPending) return null;

if (!data?.length && !hasFilters) return <ContactEmpty />;

Expand Down
4 changes: 2 additions & 2 deletions examples/crm/src/deals/DealList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from 'react-admin';
import { matchPath, useLocation } from 'react-router';

import { Card, LinearProgress, Stack } from '@mui/material';
import { Card, Stack } from '@mui/material';
import { useConfigurationContext } from '../root/ConfigurationContext';
import { DealArchivedList } from './DealArchivedList';
import { DealCreate } from './DealCreate';
Expand Down Expand Up @@ -63,7 +63,7 @@ const DealLayout = () => {
const { data, isPending, filterValues } = useListContext();
const hasFilters = filterValues && Object.keys(filterValues).length > 0;

if (isPending) return <LinearProgress />;
if (isPending) return null;
if (!data?.length && !hasFilters)
return (
<>
Expand Down
3 changes: 1 addition & 2 deletions examples/crm/src/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Suspense, ReactNode } from 'react';
import { CssBaseline, Container } from '@mui/material';
import { CheckForApplicationUpdate } from 'react-admin';
import { Error, Loading, CheckForApplicationUpdate } from 'react-admin';
import { ErrorBoundary } from 'react-error-boundary';

import { Error, Loading } from 'react-admin';
import Header from './Header';

const Layout = ({ children }: { children: ReactNode }) => (
Expand Down

0 comments on commit 2bb14b9

Please sign in to comment.