Skip to content

Commit

Permalink
Merge pull request #3459 from ingef/temporarily-fix-entity-preview-fetch
Browse files Browse the repository at this point in the history
Temporarily fix entity preview fetch
  • Loading branch information
thoniTUB authored May 29, 2024
2 parents d802618 + e2220ff commit 8f6dee3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 9 additions & 5 deletions frontend/src/js/entity-history/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { useDatasetId } from "../dataset/selectors";
import { loadCSV, parseCSVWithHeaderToObj } from "../file/csv";
import { setMessage } from "../snack-message/actions";

import { canViewEntityPreview } from "../user/selectors";
import { EntityEvent, EntityId } from "./reducer";
import { isDateColumn, isSourceColumn } from "./timeline/util";

Expand All @@ -52,16 +51,21 @@ export const loadDefaultHistoryParamsSuccess = createAction(
export const useLoadDefaultHistoryParams = () => {
const dispatch = useDispatch();

const canViewHistory = useSelector<StateT, boolean>(canViewEntityPreview);
const canViewHistoryRef = useRef(canViewHistory);
canViewHistoryRef.current = canViewHistory;
// TODO: Get this to work such that we only try to load
// if the user has the permission to do so.
// So far, if we enable this, we won't load the entityHistoryDefaultParams
// on the first app load, because we'd have to time the result of /me (permissions)
// to be available before loading this.
// const canViewHistory = useSelector<StateT, boolean>(canViewEntityPreview);
// const canViewHistoryRef = useRef(canViewHistory);
// canViewHistoryRef.current = canViewHistory;

const getEntityHistoryDefaultParams = useGetEntityHistoryDefaultParams();

return useCallback(
async (datasetId: DatasetT["id"]) => {
try {
if (!canViewHistoryRef.current) return;
// if (!canViewHistoryRef.current) return;

const result = await getEntityHistoryDefaultParams(datasetId);

Expand Down
9 changes: 4 additions & 5 deletions frontend/src/js/startup/useStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ export const useStartup = ({ ready }: { ready?: boolean }) => {

useEffect(() => {
async function load() {
dispatch(resetMessage());

if (ready) {
await Promise.all([loadMe(), loadConfig()]);

loadDatasets();
dispatch(resetMessage());
await loadMe();
await loadConfig();
setTimeout(loadDatasets, 300);
}
}
load();
Expand Down

0 comments on commit 8f6dee3

Please sign in to comment.