-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[WEB-2774]fix:reordering favorites and favorite folders #6119
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0f641ec
fixed re order for favorites
vamsikrishnamathala 12743b5
fixed lint errors
vamsikrishnamathala 0a6cb1b
Merge branch 'preview' of github.com:makeplane/plane into chore-favor…
vamsikrishnamathala 23b30d0
added reorder
vamsikrishnamathala 0bec7a1
Merge branch 'preview' of github.com:makeplane/plane into chore-favor…
vamsikrishnamathala a612ec7
fixed reorder inside folder
vamsikrishnamathala b2a58a3
fixed lint issues
vamsikrishnamathala 1b124c6
memoized reorder
vamsikrishnamathala d1cc0e0
removed unnecessary comments
vamsikrishnamathala 9535a4a
seprated duplicate logic to a common file
vamsikrishnamathala 797a756
removed code comments
vamsikrishnamathala 9b494bf
Merge branch 'preview' of github.com:makeplane/plane into chore-favor…
vamsikrishnamathala 997ea5b
fixed favorite remove while reorder inside folder
vamsikrishnamathala 073cc06
fixed folder remove while reorder inside folder
vamsikrishnamathala 65248c7
fixed-reorder issue
vamsikrishnamathala 6501cdd
added last child to drop handled
vamsikrishnamathala e1e7865
fixed orderby function
vamsikrishnamathala 9541f5b
removed unncessasary comments
vamsikrishnamathala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Consider sequence normalization and bounds checking
The current sequence calculation has several potential issues:
Consider implementing sequence normalization:
reOrderFavorite = async (workspaceSlug: string, favoriteId: string, destinationId: string, edge: string | undefined) => { const initialSequence = this.favoriteMap[favoriteId].sequence; try { - let resultSequence = 10000; + const SEQUENCE_STEP = 1000; + const MAX_SEQUENCE = 1000000; + + // Normalize sequences if they get too large + const normalizeSequences = () => { + const favorites = Object.values(this.favoriteMap); + if (favorites.some(f => f.sequence > MAX_SEQUENCE)) { + const sorted = orderBy(favorites, "sequence", "desc"); + sorted.forEach((fav, idx) => { + fav.sequence = (sorted.length - idx) * SEQUENCE_STEP; + }); + } + }; let resultSequence; if (edge) { const sortedIds = orderBy(Object.values(this.favoriteMap), "sequence", "desc").map((fav: IFavorite) => fav.id); const destinationSequence = this.favoriteMap[destinationId]?.sequence || undefined; if (destinationSequence) { const destinationIndex = sortedIds.findIndex((id) => id === destinationId); if (edge === "reorder-above") { const prevSequence = this.favoriteMap[sortedIds[destinationIndex - 1]]?.sequence || destinationSequence + SEQUENCE_STEP; resultSequence = (destinationSequence + prevSequence) / 2; } else { const nextSequence = this.favoriteMap[sortedIds[destinationIndex + 1]]?.sequence || Math.max(0, destinationSequence - SEQUENCE_STEP); resultSequence = (destinationSequence + nextSequence) / 2; } } } + normalizeSequences();📝 Committable suggestion