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

Reducer: toggleSubtree #711

Open
1 task
raineorshine opened this issue May 31, 2020 · 4 comments
Open
1 task

Reducer: toggleSubtree #711

raineorshine opened this issue May 31, 2020 · 4 comments
Labels
feature New feature or request

Comments

@raineorshine
Copy link
Contributor

raineorshine commented May 31, 2020

Define a new reducer toggleSubtree and write unit tests.

toggleSubtree(state: State, context: Context, subtree: string, { matchChild: boolean } = {}): State

Give the following subtree:

- a
  - b
    - c
  • toggleSubtree(state, context, subtree) should insert the subtree if {context}/a does not exist.
  • toggleSubtree(state, context, subtree) should remove {context}/a and all descendants if {context}/a exists.
  • toggleSubtree(state, context, subtree, { matchChild: true }) should insert the subtree if {context}/a does not exist or if {context}/a/b does not exist.
  • toggleSubtree(state, context, subtree, { matchChild: true }) should remove {context}/a and all descendants if {context}/a/b exists.

Use importText to convert the subtree to thought updates.

@raineorshine raineorshine added the feature New feature or request label May 31, 2020
@raineorshine raineorshine mentioned this issue May 31, 2020
1 task
@raineorshine raineorshine changed the title toggleSubtree Reducer: toggleSubtree May 31, 2020
@shresthabijay shresthabijay self-assigned this Jul 11, 2020
@shresthabijay
Copy link
Contributor

@raineorshine We cannot use importText action creator inside a reducer. Either we have to make toggleSubtree an action-creator or use importHTML inside toggleSubtree. The later one will need moving rawTextToHTML function from importText to a separate util function, so that we can use it inside toggleSubtree.

@shresthabijay
Copy link
Contributor

@raineorshine We need to specifically parse a and b from the string. We need to update importHTML function to do return these or we can just pass those data to the toggleSubtree directly. What is your view on this ?

@raineorshine
Copy link
Contributor Author

@raineorshine We cannot use importText action creator inside a reducer. Either we have to make toggleSubtree an action-creator or use importHTML inside toggleSubtree. The later one will need moving rawTextToHTML function from importText to a separate util function, so that we can use it inside toggleSubtree.

Yes, those are all desirable changes.

@raineorshine We need to specifically parse a and b from the string. We need to update importHTML function to do return these or we can just pass those data to the toggleSubtree directly. What is your view on this ?

Perhaps we should change the signature to accept JSON rather than a string. We can always convert the string to JSON beforehand. Then the imported root and its children will be easily accessible.

I'm going to put this on hold until #714 is complete. There is some overlap.

@raineorshine raineorshine added the hold Pause development label Jul 11, 2020
@shresthabijay
Copy link
Contributor

Perhaps we should change the signature to accept JSON rather than a string. We can always convert the string to JSON beforehand. Then the imported root and its children will be easily accessible.

I'm going to put this on hold until #714 is complete. There is some overlap.

Sure.

@raineorshine raineorshine removed the hold Pause development label Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants