Skip to content

Commit

Permalink
fix: change filter behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisobdam committed Nov 6, 2020
1 parent c09f533 commit 59e30b4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
const location = isDev ? {} : useLocation();
const { actionId, modelId, variableId } = formData;
const formVariable = getActionInput(variableId);
const hasFilter = modelId && filter && Object.keys(filter).length > 0;

const getFilter = React.useCallback(() => {
if (isDev || !currentRecord || !modelId) {
Expand All @@ -46,10 +45,12 @@
};
}, [isDev, filter, currentRecord, modelId]);

const applyFilter = getFilter();

const { loading: isFetching, data: records, error: err } =
(hasFilter &&
(applyFilter &&
useAllQuery(modelId, {
filter: getFilter(),
filter: applyFilter,
skip: 0,
take: 1,
})) ||
Expand Down Expand Up @@ -123,7 +124,7 @@
};

const renderContent = loading => {
if (!hasFilter || isDev) {
if (!applyFilter || isDev) {
return <Children loading={loading}>{children}</Children>;
}
if (isFetching) return 'Loading...';
Expand Down

0 comments on commit 59e30b4

Please sign in to comment.