Skip to content

Commit

Permalink
fix(view): Apply default value when absent
Browse files Browse the repository at this point in the history
  • Loading branch information
aikuci committed Jun 21, 2024
1 parent 7a0f097 commit 99165d3
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const ViewPickerCreateOrEditContentEffect = () => {
viewPickerSelectedIconState,
viewPickerInputNameState,
viewPickerReferenceViewIdState,
viewPickerIsPersistingState,
viewPickerKanbanFieldMetadataIdState,
viewPickerTypeState,
viewPickerIsDirtyState,
Expand All @@ -32,8 +31,12 @@ export const ViewPickerCreateOrEditContentEffect = () => {
);

const viewPickerIsDirty = useRecoilValue(viewPickerIsDirtyState);

const viewPickerIsPersisting = useRecoilValue(viewPickerIsPersistingState);
const viewPickerSelectedIcon = useRecoilValue(viewPickerSelectedIconState);
const viewPickerInputName = useRecoilValue(viewPickerInputNameState);
const viewPickerKanbanFieldMetadataId = useRecoilValue(
viewPickerKanbanFieldMetadataIdState,
);
const viewPickerType = useRecoilValue(viewPickerTypeState);

const { viewsOnCurrentObject } = useGetCurrentView();
const referenceView = viewsOnCurrentObject.find(
Expand All @@ -43,24 +46,24 @@ export const ViewPickerCreateOrEditContentEffect = () => {
const { availableFieldsForKanban } = useGetAvailableFieldsForKanban();

useEffect(() => {
if (
isDefined(referenceView) &&
!viewPickerIsPersisting &&
!viewPickerIsDirty
) {
setViewPickerSelectedIcon(referenceView.icon);
setViewPickerInputName(referenceView.name);
setViewPickerKanbanFieldMetadataId(referenceView.kanbanFieldMetadataId);
setViewPickerType(referenceView.type);
if (isDefined(referenceView)) {
if (!viewPickerSelectedIcon)
setViewPickerSelectedIcon(referenceView.icon);
if (!viewPickerInputName) setViewPickerInputName(referenceView.name);
if (!viewPickerKanbanFieldMetadataId)
setViewPickerKanbanFieldMetadataId(referenceView.kanbanFieldMetadataId);
if (!viewPickerType) setViewPickerType(referenceView.type);
}
}, [
referenceView,
viewPickerSelectedIcon,
viewPickerInputName,
viewPickerKanbanFieldMetadataId,
viewPickerType,
setViewPickerSelectedIcon,
setViewPickerInputName,
setViewPickerKanbanFieldMetadataId,
setViewPickerSelectedIcon,
setViewPickerType,
viewPickerIsPersisting,
viewPickerIsDirty,
]);

useEffect(() => {
Expand Down

0 comments on commit 99165d3

Please sign in to comment.