Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| CREATE_CHANNEL = "createChannel", | ||
| GET_CHANNELS = "getChannels", | ||
| GET_ALL_CHANNELS_SEARCH = "getChannelDirectory", | ||
| GET_CHANNEL_MEMBERS = "abc", |
| userId: typeof username === 'string' ? username : userId, | ||
| username: typeof username === 'string' ? username : userId, | ||
| })) | ||
| : activeChannelMembers || []; |
There was a problem hiding this comment.
Bug: Wrong userId assigned in DM mentions extraction
In handleEditedMessage, when preparing membersForMentions for DMs, the userId field is incorrectly populated with the username instead of the actual user ID. This happens because the map's key (user ID) is overwritten by its value (username) during array transformation, causing extractAndAddMentions to return usernames in place of user IDs for edited DM message mentions.
| const usernames = userEntries.map(([_, user]) => { | ||
| // @ts-expect-error - value is not typed | ||
| return (user.username as string).toLowerCase(); | ||
| }); |
There was a problem hiding this comment.
Bug: Accessing .username on string values causes TypeError
The chatMembers and membersList props are Map<string, string>, but functions like isValidIdentityId in DMHeader and extractAndAddMentions in ChatContainer's sendMessage expect map values to be objects with a username property. This causes a TypeError in DMHeader and silently prevents mention extraction in sendMessage.
Additional Locations (1)
| ); | ||
| const isDM = activeChatRef.current?.type === "direct_message"; | ||
|
|
||
| // @ts-expect-error - membersListRef.current is a Map |
There was a problem hiding this comment.
Bug: Map passed to function expecting array of objects
The extractAndAddMentions function is called with membersListRef.current which is a Map<string, string>, but the function expects an array of objects with userId and username properties. Iterating over a Map yields [key, value] tuples, not objects with named properties. When the function accesses user.username and user.userId, these will be undefined, causing mentions extraction to silently fail and return empty arrays.
| async getChannels(): ApiResponse<ChannelDataResponse[]> { | ||
| try { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const response = await getJsonRpcClient().execute<any, Channels>( |
There was a problem hiding this comment.
createChannel ignores visibility, readOnly, and moderator settings
The createChannel implementation only sends name to the backend via argsJson, but the caller in ChannelHeader.tsx passes channel_type (public/private visibility), readOnly, moderators, links_allowed, and created_at. All these configuration options are silently ignored, meaning newly created channels will not have the intended visibility settings, read-only mode, or moderator assignments.
Additional Locations (1)
| GROUP = "Default", | ||
| PUBLIC = "public", | ||
| PRIVATE = "private", | ||
| GROUP = "default", |
There was a problem hiding this comment.
ChannelType enum change breaks private channel detection
The ChannelType enum values were changed from PascalCase ("Private") to lowercase ("private"), but existing code in DetailsDropdown.tsx and DetailsContainer.tsx still compares against the old PascalCase value "Private". This means private channels will not be detected correctly, causing the wrong icon (public hashtag instead of lock) to display for private channels throughout the UI.
Additional Locations (2)
|
|
||
| // Transform messages from backend format to frontend format | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const transformedMessages = getMessagesObject.messages.map((msg: any) => { |
There was a problem hiding this comment.
Missing array check before mapping messages causes crash
Medium Severity
The code calls getMessagesObject.messages.map(...) without verifying that messages is an array. While getMessagesObject is null-checked, if the API returns an object without a messages property (e.g., { total_count: 0, start_position: 0 }), calling .map() on undefined will throw a TypeError and crash the application.
| // } else if (response.error) { | ||
| // setError(response.error.message || "Failed to fetch channel members"); | ||
| // } | ||
| setChannelUsers({}); |
There was a problem hiding this comment.
fetchChannelMembers is disabled and returns empty object
High Severity
The fetchChannelMembers function has its API call commented out and unconditionally sets channelUsers to an empty object {}. This breaks any functionality that depends on fetching channel members, including member lists and user lookups. The function accepts a _channelId parameter (prefixed with underscore indicating it's unused) but does nothing with it.
| if (!membersMap.has(moderator.publicKey)) { | ||
| upsertMember(moderator, true); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Missing null checks on channel arrays causes crash
Medium Severity
The code calls channel.moderators.map(...) and channel.members.forEach(...) without checking if these properties are valid arrays. If the API returns a channel object with null or undefined for members or moderators, the code will crash with a TypeError when attempting to call array methods on non-array values.
|
Outdated, needs to be redone. |
Curb JS - Frontend
Description
Contains frontend for Curb JS -> simplified and changes some components, logic, hooks, handlers
Note
Modernizes the app to the new Calimero client/backend contract and expands channel management.
@calimero-network/calimero-clientto1.24.1and realignClientMethodnames, payloads, and types (lowercaseChannelType, new DTOs, normalized DM structures)clientApi/data sources: new channel directory (getChannels,getChannelDirectory), moderator ops (promoteModerator,demoteModerator,removeUserFromChannel),deleteChannel, revamped messages (args/result mapping, reactions/attachments normalization), andgetNonMemberUsersreturning username mapschannelMetathrough navbar/containers, show members/moderators, add member invites with autocomplete, role actions (promote/demote/remove), and optional channel delete; improved message edit/mentions and thread pagination; safer create-channel error handlinguseChannelsmaps members/moderators/unread toChannelMeta;useChannelMembersreturns records and fetches invitees; search page uses new directory and join/leave flowscreateContext; update.gitignoreWritten by Cursor Bugbot for commit 96eb95e. This will update automatically on new commits. Configure here.