Skip to content

Migrate utilities from UrlContextProvider to Zustand stores #269

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

Open
7 tasks
coderabbitai bot opened this issue May 14, 2025 · 2 comments
Open
7 tasks

Migrate utilities from UrlContextProvider to Zustand stores #269

coderabbitai bot opened this issue May 14, 2025 · 2 comments

Comments

@coderabbitai
Copy link

coderabbitai bot commented May 14, 2025

Background

The states provided by the StateContextProvider have been migrated to Zustand stores in PR #224. As discussed in issue #211, the utilities in UrlContextProvider should also be migrated to Zustand to improve maintainability.

Objective

Migrate the utilities from UrlContextProvider to appropriate Zustand stores following the patterns established in PR #224.

Tasks

(drafted by @coderabbitai and updated by @junhaoliao on May 18)

  • Identify all utilities in UrlContextProvider
  • Determine appropriate Zustand store for current states managed by UrlContextProvider
    • filePath: logFileStore? (We should remove the current reference in contextStore).
    • logEventIdx: viewStore?
    • isPrettified: viewStore?
  • Update components to use the new store(s) instead of the context
  • On app init (e.g., an useEffect hook in AppController with [] dependency array), call getWindowUrlSearchParams() and getWindowUrlHashParams(), and set corresponding states; also, window.addEventListener("hashchange", handleHashChange); where handleHashChange() calls getWindowUrlHashParams() and set corresponding states.
  • Remove the UrlContextProvider once migration is complete
  • Update existing utility functions in UrlContextProvider.tsx
    • updateWindowUrlHashParams should no longer call window.dispatchEvent(new HashChangeEvent("hashchange"))
    • Consider relocating the existing ones into src/utils/url.ts
  • If the above changes are already more than 400 lines (the YScope PR line limit), propose unit testing plan in the PR description; otherwise, if time allows, write unit tests for the URL utilities.

References

Assignee

@junhaoliao

@junhaoliao
Copy link
Member

@zzxthehappiest I updated the "Tasks" section above for the items we discussed offline. Feel free to let me know if I missed anything or if you have any question.

@zzxthehappiest
Copy link
Contributor

Thank you! I will start working on this tomorrow and finish it in a couple of days to unblock others (and my another PR).

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

No branches or pull requests

2 participants