Feat/leave-brain#168
Conversation
|
@ad1tyayadav Leave Brain Functionality working. But there is some issues in code structure.
|
hi @ad1tyayadav, kindly look into this and let us know if you need any support. thanks |
|
@chsjd I’ve made all the requested changes.....let me know if anything else needs to be updated. |
|
The convertToShared functionality was removed but it’s still required. Missing/removed items: Additionally, when I run bash build.sh to create a production build, it fails with these TypeScript errors: So, fix this issue and make sure do not remove existing functionality. Once all done then run it in production mode if all working fine then create pr after then we will review it again. |
0454626 to
4ff65c6
Compare
|
@ad1tyayadav let me know once above commented all issue fixed. Add comment and mention what you fixed so can verify and merge pr. |
|
@chsjd All issues have been fixed. Here's what I addressed:- 1. Restored Convert to Shared Functionality
2. Fixed TypeScript Build Errors
3. Contant.ts Improvements
5. Leave Brain Feature (Original PR functionality)
Files Changed:
|
|
@ad1tyayadav CONVERT TO SHARED functionality still not working and also in sidebar I can not see leave brain icon so how user can leave brain. Do one thing take a new clone of weam and add leave brain functionality in this. Create a pr after testing and let me know so we will verify and merge it in main. |
|
okay I'll do soon |
JiwaniZakir
left a comment
There was a problem hiding this comment.
In leaveBrainAction (brains.ts), getSessionUser() is awaited before the brainId validation check, meaning an unnecessary async session lookup happens even when brainId is empty — the guard should be moved above the getSessionUser() call.
The isOwner comparison in BrainList.tsx (b.user.id === currentUser._id) uses strict equality between two fields that may be of different types — b.user.id likely comes from a serialized API response (string) while currentUser._id may be a MongoDB ObjectId. This comparison should be verified or explicitly coerced to strings (e.g., String(b.user.id) === String(currentUser._id)) to avoid silent permission mismatches where a user who is the owner is shown the "Leave" button instead of the edit controls.
Using MODULE_ACTIONS.UNSHARE as the underlying API action for leaving a brain is semantically ambiguous — if the backend's unshare endpoint is designed to remove any member (not just the caller), then the user_id passed in the body could be manipulated client-side. It's worth confirming the backend enforces that a user can only remove themselves via this flow, or that a dedicated leave endpoint is used instead.
Summary
This PR implements the "Leave Brain" functionality for invited users, addressing issue #84. Currently, invited users cannot voluntarily leave Brains they no longer wish to participate in, leading to dashboard clutter and poor user experience. This feature empowers users to manage their Brain memberships autonomously.
Key Changes:
LeaveBrainButtoncomponent with confirmation modalChange Type
##Demo
WeamAi.mp4
Testing
Test Configuration:
Test Instructions:
As an invited user:
As a Brain owner:
Edge Cases:
Checklist
Additional Notes
Backend Integration:
/api/brain/leaveendpoint with proper brainId parameterUI/UX Considerations:
Security:
Summary by CodeRabbit
New Features
UI Improvements
Security/Access