diff --git a/lib/utils/delete-message-utils.js b/lib/utils/delete-message-utils.js --- a/lib/utils/delete-message-utils.js +++ b/lib/utils/delete-message-utils.js @@ -21,7 +21,10 @@ import { isComposableMessageType } from '../types/message-types.js'; import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from '../types/thread-permission-types.js'; -import { thickThreadTypes } from '../types/thread-types-enum.js'; +import { + thickThreadTypes, + threadTypeIsThick, +} from '../types/thread-types-enum.js'; const deletedMessageText = 'Deleted message'; @@ -83,6 +86,7 @@ function useCanDeleteMessage( threadInfo: ThreadInfo, targetMessageInfo: ?MessageInfo, + threadCreatedFromMessage: boolean, ): boolean { const currentUserInfo = useSelector(state => state.currentUserInfo); const canDeleteOwnMessages = useThreadHasPermission( @@ -110,6 +114,17 @@ return true; } + if ( + threadTypeIsThick(threadInfo.type) && + (targetMessageInfo.time < threadInfo.creationTime || + threadCreatedFromMessage) + ) { + // This code blocks deleting a sidebar source in thick threads - we + // don't handle it correctly now. We have a task to track + // https://linear.app/comm/issue/ENG-10528/handle-message-edit-and-delete-of-a-sidebar-source-in-thick-threads + return false; + } + return ( currentUserInfo.id === targetMessageInfo.creator.id && canDeleteOwnMessages ); diff --git a/native/chat/multimedia-message.react.js b/native/chat/multimedia-message.react.js --- a/native/chat/multimedia-message.react.js +++ b/native/chat/multimedia-message.react.js @@ -258,6 +258,7 @@ const canDeleteMessage = useCanDeleteMessage( props.item.threadInfo, props.item.messageInfo, + !!props.item.threadCreatedFromMessage, ); return ( - [ - replyAction, - sidebarAction, - copyAction, - reactAction, - togglePinAction, - editAction, - deleteAction, - ].filter(Boolean), - [ + + return React.useMemo(() => { + if (item.deleted) { + return []; + } + return [ replyAction, sidebarAction, copyAction, @@ -446,8 +444,17 @@ togglePinAction, editAction, deleteAction, - ], - ); + ].filter(Boolean); + }, [ + item.deleted, + replyAction, + sidebarAction, + copyAction, + reactAction, + togglePinAction, + editAction, + deleteAction, + ]); } const undefinedTooltipSize = {