Changeset View
Changeset View
Standalone View
Standalone View
native/chat/robotext-message.react.js
Show All 35 Lines | const { | ||||
item, | item, | ||||
navigation, | navigation, | ||||
route, | route, | ||||
focused, | focused, | ||||
toggleFocus, | toggleFocus, | ||||
verticalBounds, | verticalBounds, | ||||
...viewProps | ...viewProps | ||||
} = props; | } = props; | ||||
const { isViewer } = item.messageInfo.creator; | |||||
let timestamp = null; | let timestamp = null; | ||||
if (focused || item.startsConversation) { | if (focused || item.startsConversation) { | ||||
timestamp = ( | timestamp = ( | ||||
<Timestamp time={item.messageInfo.time} display="lowContrast" /> | <Timestamp time={item.messageInfo.time} display="lowContrast" /> | ||||
); | ); | ||||
} | } | ||||
const styles = useStyles(unboundStyles); | const styles = useStyles(unboundStyles); | ||||
let inlineSidebar = null; | let inlineSidebar = null; | ||||
if (item.threadCreatedFromMessage) { | if (item.threadCreatedFromMessage) { | ||||
const position = isViewer ? 'right' : 'left'; | |||||
inlineSidebar = ( | inlineSidebar = ( | ||||
<View style={styles.sidebar}> | <View style={styles.sidebar}> | ||||
<InlineSidebar threadInfo={item.threadCreatedFromMessage} /> | <InlineSidebar | ||||
threadInfo={item.threadCreatedFromMessage} | |||||
position={position} | |||||
/> | |||||
</View> | </View> | ||||
); | ); | ||||
} | } | ||||
const keyboardState = React.useContext(KeyboardContext); | const keyboardState = React.useContext(KeyboardContext); | ||||
const key = messageKey(item.messageInfo); | const key = messageKey(item.messageInfo); | ||||
const onPress = React.useCallback(() => { | const onPress = React.useCallback(() => { | ||||
const didDismiss = | const didDismiss = | ||||
Show All 29 Lines | (x, y, width, height, pageX, pageY) => { | ||||
const messageTop = pageY; | const messageTop = pageY; | ||||
const messageBottom = pageY + height; | const messageBottom = pageY + height; | ||||
const boundsTop = verticalBounds.y; | const boundsTop = verticalBounds.y; | ||||
const boundsBottom = verticalBounds.y + verticalBounds.height; | const boundsBottom = verticalBounds.y + verticalBounds.height; | ||||
const belowMargin = 20; | const belowMargin = 20; | ||||
const belowSpace = robotextMessageTooltipHeight + belowMargin; | const belowSpace = robotextMessageTooltipHeight + belowMargin; | ||||
const { isViewer } = item.messageInfo.creator; | |||||
const aboveMargin = isViewer ? 30 : 50; | const aboveMargin = isViewer ? 30 : 50; | ||||
const aboveSpace = robotextMessageTooltipHeight + aboveMargin; | const aboveSpace = robotextMessageTooltipHeight + aboveMargin; | ||||
let location = 'below', | let location = 'below', | ||||
margin = 0; | margin = 0; | ||||
if ( | if ( | ||||
messageBottom + belowSpace > boundsBottom && | messageBottom + belowSpace > boundsBottom && | ||||
messageTop - aboveSpace > boundsTop | messageTop - aboveSpace > boundsTop | ||||
Show All 11 Lines | (x, y, width, height, pageX, pageY) => { | ||||
visibleEntryIDs, | visibleEntryIDs, | ||||
location, | location, | ||||
margin, | margin, | ||||
item, | item, | ||||
}, | }, | ||||
key: getMessageTooltipKey(item), | key: getMessageTooltipKey(item), | ||||
}); | }); | ||||
}, | }, | ||||
[item, props.navigation, props.route.key, verticalBounds, visibleEntryIDs], | [ | ||||
item, | |||||
props.navigation, | |||||
props.route.key, | |||||
verticalBounds, | |||||
visibleEntryIDs, | |||||
isViewer, | |||||
], | |||||
); | ); | ||||
const onLongPress = React.useCallback(() => { | const onLongPress = React.useCallback(() => { | ||||
if (keyboardState && keyboardState.dismissKeyboardIfShowing()) { | if (keyboardState && keyboardState.dismissKeyboardIfShowing()) { | ||||
return; | return; | ||||
} | } | ||||
if (visibleEntryIDs.length === 0) { | if (visibleEntryIDs.length === 0) { | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |