-
Notifications
You must be signed in to change notification settings - Fork 664
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
feat: allow org members to mark projects as favorites #2040
base: main
Are you sure you want to change the base?
Conversation
@@ -271,6 +280,30 @@ export const AppLayout = ({ children }: LayoutProps) => { | |||
} | |||
}; | |||
|
|||
const addProjectToFavorites = useCallback( |
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.
A bit confused by this usecallback?
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.
And the below one
icon={faSolidStar} | ||
className="text-sm text-mineshaft-300 hover:text-mineshaft-400" | ||
onClick={(e) => { | ||
e.stopPropagation(); |
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.
Missing try catch and notification for both remove and add
favoriteWorkspaces.every((entry) => entry.id !== ws.id) | ||
); | ||
|
||
const addProjectToFavorites = useCallback( |
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 doubt - The purpose of useCallback
</div> | ||
</div> | ||
))} | ||
{[...favoriteWorkspaces, ...nonFavoriteWorkspaces].map((workspace, ind) => |
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.
I think this is unnecessarily complex. Just do a useMemo(if the list could be big or computation is a lot). Then just sort the workspace list by favorite or not and add a computed field isFavourite
</> | ||
)} | ||
<div className="mt-4 grid w-full grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4"> | ||
{isWorkspaceLoading && |
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.
Wait for isFavorite
api call to finish loading. Else the list would jump if the second api call is delayed.
Because consider the workspace loading finished. You will render everything as non favorite as favorites are not loaded yet. Then favorites would load and again list gets modified causing a jump effect.
Description 📣
Type ✨
Tests 🛠️
# Here's some code block to paste some code snippets