Skip to content

Commit cf54de1

Browse files
authored
fix public meta-analysis page (#694)
1 parent 3950cf3 commit cf54de1

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

compose/neurosynth-frontend/src/hooks/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import useGetWindowHeight from './useGetWindowHeight';
88
import useCreateAlgorithmSpecification from './metaAnalyses/useCreateAlgorithmSpecification';
99
import useGetMetaAnalysesByIds from './metaAnalyses/useGetMetaAnalysesByIds';
1010
import useGetMetaAnalysisById from './metaAnalyses/useGetMetaAnalysisById';
11+
import useGetMetaAnalysesPublic from './metaAnalyses/useGetMetaAnalysesPublic';
1112
import useGetAnnotationsByStudysetId from './analyses/useGetAnnotationsByStudysetId';
1213
import useCreatePoint from './analyses/useCreatePoint';
1314
import useUpdateStudy from './studies/useUpdateStudy';
@@ -48,6 +49,7 @@ export {
4849
useCreateAlgorithmSpecification,
4950
useGetMetaAnalysesByIds,
5051
useGetMetaAnalysisById,
52+
useGetMetaAnalysesPublic,
5153
// STUDYSETS
5254
useGetStudysets,
5355
useGetStudysetById,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { useQuery } from 'react-query';
2+
import API from 'utils/api';
3+
4+
const useGetMetaAnalysesPublic = () => {
5+
const result = useQuery(
6+
['meta-analyses', 'public'],
7+
() => API.NeurosynthServices.MetaAnalysisService.metaAnalysesGet(false),
8+
{
9+
select: (axiosResponse) => {
10+
const res = axiosResponse.data.results || [];
11+
return res;
12+
},
13+
}
14+
);
15+
16+
return result;
17+
};
18+
19+
export default useGetMetaAnalysesPublic;

compose/neurosynth-frontend/src/pages/MetaAnalyses/MetaAnalysesPage/MetaAnalysesPage.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,12 @@ import { Box, TableCell, TableRow, Typography } from '@mui/material';
22
import StateHandlerComponent from 'components/StateHandlerComponent/StateHandlerComponent';
33
import NeurosynthTable from 'components/Tables/NeurosynthTable/NeurosynthTable';
44
import NeurosynthTableStyles from 'components/Tables/NeurosynthTable/NeurosynthTable.styles';
5-
import { useGetMetaAnalysesByIds } from 'hooks';
6-
import { useProjectMetaAnalyses } from 'pages/Projects/ProjectPage/ProjectStore';
7-
import { MetaAnalysisReturn } from 'neurosynth-compose-typescript-sdk';
5+
import { useGetMetaAnalysesPublic } from 'hooks';
86
import { useHistory } from 'react-router-dom';
97

108
const MetaAnalysesPage: React.FC = (props) => {
119
const history = useHistory();
12-
const projectMetaAnalyses = useProjectMetaAnalyses() || [];
13-
let metaAnalysisIds: string[] = [];
14-
if (projectMetaAnalyses.length > 0) {
15-
if (typeof projectMetaAnalyses[0] === 'string') {
16-
metaAnalysisIds = projectMetaAnalyses as string[];
17-
} else {
18-
metaAnalysisIds = (projectMetaAnalyses as MetaAnalysisReturn[])
19-
.map((metaAnalysis) => metaAnalysis.id)
20-
.filter((id): id is string => id !== undefined);
21-
}
22-
}
23-
const { data, isLoading, isError } = useGetMetaAnalysesByIds(metaAnalysisIds);
10+
const { data, isLoading, isError } = useGetMetaAnalysesPublic();
2411

2512
return (
2613
<>

0 commit comments

Comments
 (0)