Added resolveViewCreator(members, view) that uses findWorkspaceMember…#53
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors how “view creator” display data (label + avatar) is derived and rendered on the project ViewsPage, centralizing the logic into a helper and switching avatar rendering to the shared Avatar UI component to address incorrect/missing profile pictures (issue #51).
Changes:
- Added
resolveViewCreator(members, view)to derive creator label + avatar URL usingfindWorkspaceMemberByUserIdandgetImageUrl. - Removed the previous memoized “name by id” / “avatar by id” maps and the manual initials/avatar rendering.
- Updated the list row UI to render creator avatars via the standardized
Avatarcomponent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const { label: creatorLabel, avatarSrc: creatorAvatarSrc } = resolveViewCreator( | ||
| members, | ||
| v, | ||
| ); |
There was a problem hiding this comment.
resolveViewCreator(members, v) performs findWorkspaceMemberByUserId, which linearly scans members for every row render. This is an O(sortedViews × members) lookup and is a performance regression vs the previous memoized maps. Consider building a memoized lookup (e.g., Map keyed by normalized userId/memberId) once per members change and have resolveViewCreator use that map (or pass the already-resolved member into the helper).
This pull request refactors how view creator information (name and avatar) is resolved and displayed in the
ViewsPagecomponent. Instead of using separate maps for names and avatars, the logic is centralized into a new helper function, and the UI now uses the standardizedAvatarcomponent for rendering creator avatars.Refactoring and UI improvements:
resolveViewCreatorhelper function, which determines the appropriate display name and avatar URL for a view creator based on workspace member data. [1] [2] [3]Avatarcomponent for displaying creator avatars, ensuring consistent styling and fallback handling. [1] [2]Code cleanup:
userInitialfunction and redundant manual avatar rendering logic, simplifying the codebase. [1] [2]closes Fix profile picture in project views #51