Added function to dispatch edit message action. It calls the edit message function, which communicates with the keyserver endpoint.
Details
Called the function from both web and native (iOS), and checked if the keyserver endpoint is called successfully.
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
lib/shared/edit-messages-utils.js | ||
---|---|---|
25 | In what scenario will messageID not be set? It would be easier to understand how this function is used if you included it in the same diff where you introduced the first usage | |
54–55 | Why are we doing this? Do we need this info in the reducer? | |
56 | I think you forgot to remove this console.log |
Address review comments
lib/shared/edit-messages-utils.js | ||
---|---|---|
25 |
It is not currently used anywhere, but I use it locally to test it (tooltip-utils.js): function useMessageEditAction( item: ChatMessageInfoItem, threadInfo: ThreadInfo, ): ?MessageTooltipAction { const { messageInfo } = item; const canEditMessage = useCanEditMessage(threadInfo, messageInfo); const editMessage = useEditMessage(messageInfo.id); return React.useMemo(() => { if (!canEditMessage) { return null; } if (item.messageInfoType !== 'composable') { return null; } const buttonContent = ( <SWMansionIcon icon="edit-1" size={18} disableFill={false} /> ); const onClickEdit = () => { editMessage('Test ' + new Date().toLocaleString()); }; return { actionButtonContent: buttonContent, onClick: onClickEdit, label: 'Edit', }; }, [canEditMessage, editMessage, item]); } Scenario: Here sometimes messageInfo.id can be sometimes undefined, and I cannot use condition here, before calling the useEditMessage, because of React Hook "useEditMessage" is called conditionally error. |