refactor(platform): extract blurActiveElement to infrastructure module
- Centralize duplicated Platform.OS === 'web' blur logic across 16 components - Add blurActiveElement utility to src/infrastructure/platform module - Optimize MessageBubble and ImageSegment with React.memo custom comparators - Add useMemo for computed values in MessageSegmentsRenderer - Update DTO types with is_system_notice and notice_content fields - Fix keyboard dismissal order in useChatScreen handleDismiss - Simplify userStore follow/unfollow state updates - Remove unnecessary TypeScript type assertions throughout codebase
This commit is contained in:
@@ -31,7 +31,7 @@ const MAX_WIDTH_RATIO = {
|
||||
desktop: 0.55,
|
||||
};
|
||||
|
||||
export const MessageBubble: React.FC<MessageBubbleProps> = ({
|
||||
const MessageBubbleInner: React.FC<MessageBubbleProps> = ({
|
||||
message,
|
||||
index,
|
||||
currentUserId,
|
||||
@@ -481,11 +481,37 @@ const segmentStyles = StyleSheet.create({
|
||||
minWidth: 120,
|
||||
},
|
||||
pureImageBubble: {
|
||||
// 纯图片消息:去除内边距,让图片紧贴气泡边缘
|
||||
paddingHorizontal: 0,
|
||||
paddingVertical: 0,
|
||||
overflow: 'hidden',
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
});
|
||||
|
||||
export const MessageBubble = React.memo(MessageBubbleInner, (prev, next) => {
|
||||
if (prev.message.id !== next.message.id) return false;
|
||||
if (prev.message.status !== next.message.status) return false;
|
||||
if (prev.message.segments !== next.message.segments) return false;
|
||||
if (prev.message.sender_id !== next.message.sender_id) return false;
|
||||
if (prev.message.is_system_notice !== next.message.is_system_notice) return false;
|
||||
if (prev.message.category !== next.message.category) return false;
|
||||
if (prev.message.seq !== next.message.seq) return false;
|
||||
if (prev.message.sender !== next.message.sender) return false;
|
||||
if (prev.message.notice_content !== next.message.notice_content) return false;
|
||||
if (prev.index !== next.index) return false;
|
||||
if (prev.currentUserId !== next.currentUserId) return false;
|
||||
if (prev.otherUserLastReadSeq !== next.otherUserLastReadSeq) return false;
|
||||
if (prev.selectedMessageId !== next.selectedMessageId) return false;
|
||||
if (prev.isGroupChat !== next.isGroupChat) return false;
|
||||
if (prev.groupMembers !== next.groupMembers) return false;
|
||||
if (prev.currentUser !== next.currentUser) return false;
|
||||
if (prev.otherUser !== next.otherUser) return false;
|
||||
if (prev.messageMap !== next.messageMap) return false;
|
||||
if (prev.onLongPress !== next.onLongPress) return false;
|
||||
if (prev.onImagePress !== next.onImagePress) return false;
|
||||
if (prev.onReplyPress !== next.onReplyPress) return false;
|
||||
if (prev.shouldShowTime !== next.shouldShowTime) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
export default MessageBubble;
|
||||
|
||||
Reference in New Issue
Block a user