fix(sharings): deduplicate transient shared-drive entries#3933
Conversation
When a folder is shared from Sharings, the view can briefly receive that same file twice: the real Drive entry and a transformed shared-drive entry. The transformed entry uses the shared-drives magic directory, which is rendered as /sharings in the file path column. Deduplicate by document id after merging the query result with transformed shared-drive entries, and prefer the real Drive entry when both representations are present.
Walkthrough
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Gates Passed
3 Quality Gates Passed
See analysis details in CodeScene
Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
BundleMonFiles updated (1)
Unchanged files (19)
Total files change +153B +0.01% Groups updated (1)
Unchanged groups (2)
Final result: ✅ View report in BundleMon website ➡️ |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/modules/views/Sharings/useFilteredSharings.spec.jsx (1)
67-71: 💤 Low valueConsider adding a test for the reverse order scenario.
The current test verifies
[sharedDrivesFolder, rootFolder]→[rootFolder]. Adding a test for[rootFolder, sharedDrivesFolder]→[rootFolder]would confirm the implementation correctly preserves the real entry regardless of input order.🧪 Suggested additional test case
it('deduplicates same-id transient entries by keeping the regular Drive entry', () => { const result = deduplicateSharingShortcuts([sharedDrivesFolder, rootFolder]) expect(result).toEqual([rootFolder]) }) + + it('keeps the regular Drive entry when it appears first', () => { + const result = deduplicateSharingShortcuts([rootFolder, sharedDrivesFolder]) + + expect(result).toEqual([rootFolder]) + })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/modules/views/Sharings/useFilteredSharings.spec.jsx` around lines 67 - 71, Add a new test case in the same test file for the deduplicateSharingShortcuts function that verifies the reverse input order scenario. The test should pass the array [rootFolder, sharedDrivesFolder] to deduplicateSharingShortcuts and assert that it still returns [rootFolder], confirming that the function correctly preserves the regular Drive entry regardless of whether it appears first or second in the input order.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/modules/views/Sharings/useFilteredSharings.spec.jsx`:
- Around line 67-71: Add a new test case in the same test file for the
deduplicateSharingShortcuts function that verifies the reverse input order
scenario. The test should pass the array [rootFolder, sharedDrivesFolder] to
deduplicateSharingShortcuts and assert that it still returns [rootFolder],
confirming that the function correctly preserves the regular Drive entry
regardless of whether it appears first or second in the input order.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3f382c25-306b-4c3d-b94d-8df579215cf5
📒 Files selected for processing (2)
src/modules/views/Sharings/useFilteredSharings.jsxsrc/modules/views/Sharings/useFilteredSharings.spec.jsx
|
Owner or recipient or both have the issue? |
@zatteo Only the owner |
When a folder is shared from Sharings, the view can briefly receive that same file twice: the real Drive entry and a transformed shared-drive entry. The transformed entry uses the shared-drives magic directory, which is rendered as /sharings in the file path column.
Deduplicate by document id after merging the query result with transformed shared-drive entries, and prefer the real Drive entry when both representations are present.
https://app.notion.com/p/linagora/Folders-doubling-in-sherings-38262718bad180a4ac3de913943d4707?source=copy_link
Summary by CodeRabbit
Bug Fixes
Tests