Skip to content

Commit

Permalink
fix(preferences): initialize state with user prefs check
Browse files Browse the repository at this point in the history
  • Loading branch information
rifont committed Sep 30, 2024
1 parent bda2d7e commit fc8df8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export const CloudWorkflowSettingsSidePanel: FC<CloudWorkflowSettingsSidePanelPr
const { templateId: workflowId = '' } = useParams<{ templateId: string }>();
const [searchParams] = useSearchParams();
const { isLoading, workflowUserPreferences, workflowResourcePreferences } = useCloudWorkflowPreferences(workflowId);
const { setValue } = useFormContext<WorkflowDetailFormContext>();
const { setValue, getValues } = useFormContext<WorkflowDetailFormContext>();

useEffect(() => {
if (workflowUserPreferences !== undefined) {
if (workflowUserPreferences !== undefined && getValues('preferences') === undefined) {
setValue('preferences', workflowUserPreferences, { shouldDirty: false });
}
}, [setValue, workflowUserPreferences]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const WorkflowSubscriptionPreferences: FC<WorkflowSubscriptionPreferences
updateWorkflowPreferences,
arePreferencesDisabled,
}) => {
const [isOverridingPreferences, setIsOverridingPreferences] = useState(false);
const [isOverridingPreferences, setIsOverridingPreferences] = useState(workflowUserPreferences !== null);
// Use the user preferences if they exist, otherwise fall back to the resource preferences
const [preferences, setPreferences] = useState<WorkflowPreferences>(
workflowUserPreferences || workflowResourcePreferences!
Expand Down

0 comments on commit fc8df8d

Please sign in to comment.