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

Implement the left sidebar #864

Conversation

jfrader
Copy link
Contributor

@jfrader jfrader commented May 10, 2023

Resolves GEY-2204

  • Refactors the ProjectContainer and ProjectProvider to avoid network-only calls and make navigation between entries and back to project without reloading everything, and also avoiding passing props all the way down at least for the useProjectState. We can improve it even further by doing something similar with the funding flow, avoiding to pass all the setters and getters to every child

  • Removed several pieces of repeated code that happened when fetching a project, and the fetch itself is now in the ProjectProvider.

  • Missing the "active" state of the navigation as I still looking for a best way to detect which one should be active. Intersection Observer has performance problems, left commented out for now.

Copy link
Collaborator

@sajald77 sajald77 left a comment

Choose a reason for hiding this comment

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

Great job @fran. Added a couple of inline comments, but nothing of a blocker.

Comment on lines 1 to 28
import { RefObject, useEffect, useMemo, useState } from 'react'

export function useOnScreen(ref: RefObject<HTMLElement>) {
const [isIntersecting, setIntersecting] = useState(false)

const observer = useMemo(
() =>
new IntersectionObserver(
([entry]) => entry && setIntersecting(entry.isIntersecting),
{
threshold: 0.1,
},
),
[],
)

useEffect(() => {
if (!ref.current) {
return
}

observer.observe(ref.current)
return () => observer.disconnect()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return isIntersecting
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you end up not using the useOnScreen hook. We can probably remove it if so.

Also what was the intension here, this seems a little complex method to know if the item is on screen.

It might be easier to check with scrollHeight of the object.

Copy link
Collaborator

Choose a reason for hiding this comment

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

One more thing, does this include the changes mick mentioned or will that be a separate PR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it doesn't include that yet

@jfrader jfrader merged commit 68a3e8f into fran/gey-1721-allow-funder-to-login-from-funding-flow May 12, 2023
@jfrader jfrader deleted the fran/gey-2204-implement-the-left-sidebar branch May 12, 2023 06:51
jfrader added a commit that referenced this pull request May 12, 2023
* feat: add profile to comment box

* fix: missing deps

* chore: improve setTarget tn

* feat: Implement the left sidebar (#864)

* refactor: make ProjectProvider avoid multiple network-only requests not needed

* feat: add project navigation in left panel

* chore: remove unused hook
jfrader added a commit that referenced this pull request May 15, 2023
* feat: add profile to comment box

* fix: missing deps

* chore: improve setTarget tn

* feat: Implement the left sidebar (#864)

* refactor: make ProjectProvider avoid multiple network-only requests not needed

* feat: add project navigation in left panel

* chore: remove unused hook
jfrader added a commit that referenced this pull request May 15, 2023
* feat: add profile to comment box

* fix: missing deps

* chore: improve setTarget tn

* feat: Implement the left sidebar (#864)

* refactor: make ProjectProvider avoid multiple network-only requests not needed

* feat: add project navigation in left panel

* chore: remove unused hook
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.

2 participants