Skip to content

Commit 943d68e

Browse files
Leslie NgoLeslie Ngo
Leslie Ngo
authored and
Leslie Ngo
committed
topic edit modal [nfc]: Rebase branch over function-component-conversion branch.
1 parent 5cc72d4 commit 943d68e

File tree

2 files changed

+36
-56
lines changed

2 files changed

+36
-56
lines changed

src/search/MessageListWrapper.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/search/SearchMessagesCard.js

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
/* @flow strict-local */
22

3-
import React, { PureComponent } from 'react';
3+
import React from 'react';
44
import type { Node } from 'react';
55
import { View } from 'react-native';
66

77
import type { Message, Narrow } from '../types';
88
import { createStyleSheet } from '../styles';
99
import LoadingIndicator from '../common/LoadingIndicator';
1010
import SearchEmptyState from '../common/SearchEmptyState';
11-
import MessageListWrapper from './MessageListWrapper';
11+
import MessageList from '../webview/MessageList';
12+
import { useTopicModalHandler } from '../boot/TopicModalProvider';
1213

1314
const styles = createStyleSheet({
1415
results: {
@@ -22,29 +23,42 @@ type Props = $ReadOnly<{|
2223
isFetching: boolean,
2324
|}>;
2425

25-
export default class SearchMessagesCard extends PureComponent<Props> {
26-
render(): Node {
27-
const { isFetching, messages, narrow } = this.props;
28-
if (isFetching) {
29-
// Display loading indicator only if there are no messages to
30-
// display from a previous search.
31-
if (!messages || messages.length === 0) {
32-
return <LoadingIndicator size={40} />;
33-
}
34-
}
26+
export default function SearchMessagesCard(props: Props): Node {
27+
const { narrow, isFetching, messages } = props;
28+
const { startEditTopic } = useTopicModalHandler();
3529

36-
if (!messages) {
37-
return null;
30+
if (isFetching) {
31+
// Display loading indicator only if there are no messages to
32+
// display from a previous search.
33+
if (!messages || messages.length === 0) {
34+
return <LoadingIndicator size={40} />;
3835
}
36+
}
3937

40-
if (messages.length === 0) {
41-
return <SearchEmptyState text="No results" />;
42-
}
38+
if (!messages) {
39+
return null;
40+
}
4341

44-
return (
45-
<View style={styles.results}>
46-
<MessageListWrapper messages={messages} narrow={narrow} />
47-
</View>
48-
);
42+
if (messages.length === 0) {
43+
return <SearchEmptyState text="No results" />;
4944
}
45+
46+
return (
47+
<View style={styles.results}>
48+
<MessageList
49+
initialScrollMessageId={
50+
// This access is OK only because of the `.length === 0` check
51+
// above.
52+
messages[messages.length - 1].id
53+
}
54+
messages={messages}
55+
narrow={narrow}
56+
showMessagePlaceholders={false}
57+
// TODO: handle editing a message from the search results,
58+
// or make this prop optional
59+
startEditMessage={() => undefined}
60+
startEditTopic={startEditTopic}
61+
/>
62+
</View>
63+
);
5064
}

0 commit comments

Comments
 (0)