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
User & Metadata Loading #5347
base: main
Are you sure you want to change the base?
User & Metadata Loading #5347
Conversation
Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Thanks!
CleanShot.2024-05-10.at.18.13.13-converted.mp4
|
Alright |
packages/twenty-front/src/App.tsx
Outdated
@@ -58,13 +60,15 @@ export const App = () => { | |||
const { pathname } = useLocation(); | |||
const pageTitle = getPageTitleFromPath(pathname); | |||
|
|||
const { loading: isPrefetchLoading } = useContext(PrefetchContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not react to isPrefetchLoading here as this will trigger re-render of the whole app.
It should be loaded in the lowest places that needs it so only this part is re-rendered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gitstart-twenty see my latest comment before treating review feedbacks. I think we should not check the prefetch loading state but the metadata and currentUser queries loading states
}; | ||
|
||
export const AppNavigationDrawer = ({ | ||
className, | ||
loading, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should provide a default = false here
margin-left: 12px; | ||
`; | ||
|
||
const StyledSkeletonLoader = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a Styled component (it's actually containing much more) so we should not prefix it with Styled and it should go in its own file NavigationDrawerItemsSkeletonLoader for example
return ( | ||
<> | ||
<StyledSkeletonLoader length={4} /> | ||
<StyledSkeletonLoader title length={2} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title props is not clear. withTitle?
@@ -39,9 +41,11 @@ export const RecordIndexPageHeader = ({ | |||
objectMetadataItem?.labelPlural ?? capitalize(objectNamePlural); | |||
|
|||
return ( | |||
<PageHeader title={pageHeaderTitle} Icon={Icon}> | |||
<PageHeader title={pageHeaderTitle} Icon={Icon} loading={loading}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should react to the loading status here. It will only re-render the Header
@@ -2,11 +2,16 @@ import React from 'react'; | |||
|
|||
import { PrefetchRunQueriesEffect } from '@/prefetch/components/PrefetchRunQueriesEffect'; | |||
|
|||
export const PrefetchContext = React.createContext({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's avoid this pattern, it will trigger re-renders. Instead, we should store this prefetch loading state in a recoil state and fetch it as low as possible.
operationSignatures: [ | ||
FIND_ALL_VIEWS_OPERATION_SIGNATURE, | ||
FIND_ALL_FAVORITES_OPERATION_SIGNATURE, | ||
], | ||
skip: !currentUser, | ||
}); | ||
|
||
useEffect(() => { | ||
setLoading(loading); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's set a recoil state direclty here
ariaLabel="Add" | ||
/> | ||
); | ||
const StyledSkeletonLoader = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above :)
@@ -42,20 +44,41 @@ const StyledNavigationDrawerCollapseButton = styled( | |||
transition: opacity ${({ theme }) => theme.animation.duration.normal}s; | |||
`; | |||
|
|||
const StyledSkeletonLoader = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same :)
@gitstart-twenty I have left comments but then I took another look at the ticket and I think there is a miscommunication. PrefetchQueries loading should impact:
User and Metadata should impact the what you actually have done in this PR. It does not change the overall strategy, I would still introduce a isMetadataLoadingState and isCurrentUserLoadingState (already exists) and leverage it where you are leveraging the prefetch loading state in this PR |
Hey @charlesBochet, |
Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Description
User & Metadata Loading
Refs
#4456
Demo
prefetch_loading.mp4
Fixes #4456