Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): retains group toggle open status #790

Merged
merged 7 commits into from
Jan 19, 2024

Conversation

shu20031026
Copy link
Contributor

Summary

It is now possible to maintain the open/closed state of group toggles using local storage.

Checklist

Copy link

changeset-bot bot commented Jan 16, 2024

🦋 Changeset detected

Latest commit: c9534f0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@viron/app Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@shu20031026 shu20031026 requested a review from nonoakij January 16, 2024 08:28
@shu20031026 shu20031026 self-assigned this Jan 16, 2024
const [endpointGroups, setEndpointGroups] = useEndpointGroupToggleState();

const endpointGroup = endpointGroups.find((group) => group.id === id);
const isOpenToggle = endpointGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps using optional chaining will improve readability, instead of using the ternary operator.

@shu20031026 shu20031026 requested a review from ejithon January 16, 2024 08:52

return groups.map((group, i) =>
i === index
? { ...group, isOpenToggle: group.isOpenToggle !== true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just using "!" operator would be sufficient to evaluate it.

isOpenToggle: !group.isOpenToggle

const isOpenToggle =
endpointGroups.find((group) => group.id === id)?.isOpenToggle ?? false;

const setIsOpenToggle = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions that start with "set" are typically considered as setters for private properties. Nonetheless, the absence of arguments in such a function could make its behavior unpredictable.

@@ -102,3 +102,6 @@ export const useEndpointGroupListItemGlobalStateValue = (
export const useEndpointGroupListItemGlobalStateSet = (
params: Parameters<typeof endpointGroupListItemSelector>[0]
) => useGlobalStateSet(endpointGroupListItemSelector(params));

export const useEndpointGroupToggleState = () =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this to useEndpointGroupListGlobalState?

@shu20031026 shu20031026 requested a review from nonoakij January 19, 2024 05:37
@nonoakij nonoakij requested a review from ejithon January 19, 2024 07:30
@nonoakij nonoakij merged commit 094433b into develop Jan 19, 2024
@nonoakij nonoakij deleted the retains-group-open-status branch January 19, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I want to remember the opening and closing of the accordion of groups
3 participants