Skip to content

Commit

Permalink
minor update.
Browse files Browse the repository at this point in the history
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
  • Loading branch information
Krishna2323 committed Jul 10, 2024
1 parent 79e5620 commit f89f46b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/libs/actions/Policy/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,21 +670,21 @@ function setPolicyRequiresTag(policyID: string, requiresTag: boolean) {
],
};

const getUpdatedTagsData = (required: boolean): OnyxUpdate => ({
key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`,
onyxMethod: Onyx.METHOD.MERGE,
value: {
...Object.keys(policyTags).reduce<PolicyTagList>((acc, key) => {
acc[key] = {
...acc[key],
required,
};
return acc;
}, {}),
},
});

if (isMultiLevelTags) {
const getUpdatedTagsData = (required: boolean): OnyxUpdate => ({
key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`,
onyxMethod: Onyx.METHOD.MERGE,
value: {
...Object.keys(policyTags).reduce<PolicyTagList>((acc, key) => {
acc[key] = {
...acc[key],
required,
};
return acc;
}, {}),
},
});

onyxData.optimisticData?.push(getUpdatedTagsData(requiresTag));
onyxData.failureData?.push(getUpdatedTagsData(!requiresTag));
onyxData.successData?.push(getUpdatedTagsData(requiresTag));
Expand Down

0 comments on commit f89f46b

Please sign in to comment.