Skip to content

Commit

Permalink
setters usage refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Dec 5, 2024
1 parent 025aa70 commit 02d7928
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/common/hooks/useProfileSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useInputsState, useProfileState, useStatusState, useUIState } from '@sr
export const useProfileSchema = () => {
const { selectedEntriesService, schemaWithDuplicatesService } = useServicesContext() as Required<ServicesParams>;
const { setCollapsibleEntries } = useUIState();
const { userValues, setUserValues, setSelectedEntries } = useInputsState();
const { setUserValues, setSelectedEntries } = useInputsState();
const { setIsEditedRecord: setIsEdited } = useStatusState();
const { schema, setSchema } = useProfileState();

Expand All @@ -27,7 +27,7 @@ export const useProfileSchema = () => {

setCollapsibleEntries(prev => deleteFromSetImmutable(prev, [entry.uuid]));
setSchema(schemaWithDuplicatesService.get());
setUserValues(Object.fromEntries(Object.entries(userValues).filter(([key]) => !deletedUuids?.includes(key))));
setUserValues(prev => Object.fromEntries(Object.entries(prev).filter(([key]) => !deletedUuids?.includes(key))));

setIsEdited(true);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/CommonStatus/CommonStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const CommonStatus: FC = () => {
const { statusMessages, setStatusMessages } = useStatusState();

const deleteMessage = (messageId?: string) => {
setStatusMessages(statusMessages.filter(({ id }) => id !== messageId));
setStatusMessages(prev => prev.filter(({ id }) => id !== messageId));
};

const deleteOldestMessage = () => deleteMessage(statusMessages[0].id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const DuplicateGroupContainer: FC<IDuplicateGroupContainer> = ({
setCollapsedEntries(prev => {
const twinsAndPrevCombined = new Set([...(twins ?? []), ...prev]);

// Can use .difference method of Set() once it's been available for some time
return twinsAndPrevCombined.size === prev.size ? deleteFromSetImmutable(prev, twins) : twinsAndPrevCombined;
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchControls/SearchControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const SearchControls: FC<Props> = ({ submitSearch, changeSegment, clearVa
const setNavigationState = useSetRecoilState(state.search.navigationState);
const resetControls = useResetRecoilState(state.search.limiters);
const setFacetsBySegments = useSetRecoilState(state.search.facetsBySegments);
const { isAdvancedSearchOpen, setIsAdvancedSearchOpen } = useUIState();
const { setIsAdvancedSearchOpen } = useUIState();
const [searchParams, setSearchParams] = useSearchParams();
const [announcementMessage, setAnnouncementMessage] = useState('');
const searchQueryParam = searchParams.get(SearchQueryParams.Query);
Expand Down Expand Up @@ -150,7 +150,7 @@ export const SearchControls: FC<Props> = ({ submitSearch, changeSegment, clearVa
<Button
type={ButtonType.Link}
className="search-button"
onClick={() => setIsAdvancedSearchOpen(!isAdvancedSearchOpen)}
onClick={() => setIsAdvancedSearchOpen(isOpen => !isOpen)}
>
<FormattedMessage id="ld.advanced" />
</Button>
Expand Down

0 comments on commit 02d7928

Please sign in to comment.