Page MenuHomePhabricator

D7735.id26141.diff
No OneTemporary

D7735.id26141.diff

diff --git a/native/chat/message-result.react.js b/native/chat/message-result.react.js
--- a/native/chat/message-result.react.js
+++ b/native/chat/message-result.react.js
@@ -13,6 +13,7 @@
import type { NavigationRoute } from '../navigation/route-names';
import { useStyles } from '../themes/colors.js';
import type { ChatMessageInfoItemWithHeight } from '../types/chat-types.js';
+import type { VerticalBounds } from '../types/layout-types.js';
type MessageResultProps = {
+item: ChatMessageInfoItemWithHeight,
@@ -23,6 +24,7 @@
+route:
| NavigationRoute<'TogglePinModal'>
| NavigationRoute<'MessageResultsScreen'>,
+ +messageVerticalBounds: ?VerticalBounds,
};
function MessageResult(props: MessageResultProps): React.Node {
@@ -40,7 +42,7 @@
navigation={props.navigation}
route={props.route}
toggleFocus={onToggleFocus}
- verticalBounds={null}
+ verticalBounds={props.messageVerticalBounds}
/>
<Text style={styles.messageDate}>
{longAbsoluteDate(props.item.messageInfo.time)}
diff --git a/native/chat/message-results-screen.react.js b/native/chat/message-results-screen.react.js
--- a/native/chat/message-results-screen.react.js
+++ b/native/chat/message-results-screen.react.js
@@ -35,6 +35,9 @@
const measureMessages = useHeightMeasurer();
const [measuredMessages, setMeasuredMessages] = React.useState([]);
+ const [messageVerticalBounds, setMessageVerticalBounds] = React.useState();
+ const scrollViewRef = React.useRef();
+
const callFetchPinnedMessages = useServerCall(fetchPinnedMessages);
const userInfos = useSelector(state => state.userStore.userInfos);
@@ -147,6 +150,21 @@
});
}, [measuredMessages]);
+ const onLayout = React.useCallback(() => {
+ scrollViewRef.current?.measure((x, y, width, height, pageX, pageY) => {
+ if (
+ height === null ||
+ height === undefined ||
+ pageY === null ||
+ pageY === undefined
+ ) {
+ return;
+ }
+
+ setMessageVerticalBounds({ height, y: pageY });
+ });
+ }, []);
+
const messageResultsToDisplay = React.useMemo(() => {
return modifiedItems.map(item => {
return (
@@ -156,12 +174,17 @@
threadInfo={threadInfo}
navigation={navigation}
route={route}
+ messageVerticalBounds={messageVerticalBounds}
/>
);
});
- }, [modifiedItems, threadInfo, navigation, route]);
+ }, [modifiedItems, threadInfo, navigation, route, messageVerticalBounds]);
- return <ScrollView>{messageResultsToDisplay}</ScrollView>;
+ return (
+ <ScrollView ref={scrollViewRef} onLayout={onLayout}>
+ {messageResultsToDisplay}
+ </ScrollView>
+ );
}
export default MessageResultsScreen;
diff --git a/native/chat/toggle-pin-modal.react.js b/native/chat/toggle-pin-modal.react.js
--- a/native/chat/toggle-pin-modal.react.js
+++ b/native/chat/toggle-pin-modal.react.js
@@ -136,6 +136,7 @@
threadInfo={threadInfo}
navigation={navigation}
route={route}
+ messageVerticalBounds={null}
/>
<View style={styles.buttonsContainer}>
<Button style={modalInfo.buttonStyle} onPress={onPress}>

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 10:25 AM (22 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2579338
Default Alt Text
D7735.id26141.diff (3 KB)

Event Timeline