Skip to content

Commit

Permalink
fix: kids-first#2991 studi page flash when loading new data
Browse files Browse the repository at this point in the history
  • Loading branch information
francisl committed Mar 23, 2021
1 parent 0592909 commit 39f1fe9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pages/studies/SidebarFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const SidebarFilters: FC<SidebarData> = (sidebarData) => {
const mappingData = sidebarData.studiesMappingResults;
const data = sidebarData.studiesResults;

if (mappingData.loadingMapping || !mappingData.extendedMapping || data.loading || !data.data) {
if (mappingData?.loadingMapping || !mappingData?.extendedMapping || data.loading || !data.data) {
return null;
}

Expand Down
24 changes: 22 additions & 2 deletions src/pages/studies/studies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,30 @@ import { Layout } from 'antd';

import styles from './studies.module.scss';

let previousData: any | null = null;
let previousMappingData: any | null = null;

const Studies: FC = () => {
const { filters } = useFilters();
const studiesResults = useGetStudiesPageData({ sqon: filters });
const studiesMappingResults = useGetExtendedMappings('study');
let studiesResults = useGetStudiesPageData({ sqon: filters });
let studiesMappingResults = useGetExtendedMappings('study');

if (studiesResults.loading || studiesMappingResults.loadingMapping) {
if (!studiesResults.data && previousData) {
studiesResults = previousData;
}

if (!studiesMappingResults.extendedMapping && previousMappingData) {
studiesMappingResults = previousMappingData;
}
}

if (studiesResults.data) {
previousData = studiesResults;
}
if (studiesMappingResults) {
previousMappingData = studiesMappingResults;
}

return (
<Layout className={styles.layout}>
Expand Down

0 comments on commit 39f1fe9

Please sign in to comment.