Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ export const useRulesEngine = ({
// The problem is the helper methods that take the entire state object.
// Refactor the helper methods (getCurrentClientValues, getCurrentClientMainData in rules/actionsCreator) to be more explicit with the arguments.
const state = useSelector(stateArg => stateArg);

// HACK: use this flag as a workaround to avoid dispatching getRulesActions when formFoundation is cached
const isNewForm = useSelector(stateArg => stateArg.formsSectionsFieldsUI['singleEvent-newEvent'] === undefined);
useEffect(() => {
if (orgUnit && program && !!formFoundation) {
if (orgUnit && program && !!formFoundation && isNewForm) {
dispatch(batchActions([
getRulesActions({
state,
Expand All @@ -43,6 +46,7 @@ export const useRulesEngine = ({
program,
orgUnit,
formFoundation,
isNewForm,
]);

return !!orgUnit && orgUnitRef.current === orgUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ test('Post process rules effects', () => {
type: 'ASSIGN',
value: null,
},
{
id: 'da1Id',
type: 'ASSIGN',
value: null,
},
{
id: 'w75KJ2mc4zz',
type: 'ASSIGN',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function postProcessRulesEffects(
foundation,
// $FlowFixMe
assignValueEffects,
hideFieldEffects,
hideFieldEffects: filteredHideFieldEffects,
});

return [
Expand Down
Loading