Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3387040
D14015.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D14015.diff
View Options
diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js
--- a/native/chat/chat-input-bar.react.js
+++ b/native/chat/chat-input-bar.react.js
@@ -344,6 +344,7 @@
+onSend: () => Promise<void>,
+isMessageEdited: (newText?: string) => boolean,
+blockNavigation: () => void,
+ +onPressJoin: () => void,
};
class ChatInputBar extends React.PureComponent<Props> {
@@ -469,7 +470,7 @@
joinButton = (
<View style={this.props.styles.joinButtonContainer}>
<Button
- onPress={this.onPressJoin}
+ onPress={this.props.onPressJoin}
iosActiveOpacity={0.85}
style={[
this.props.styles.joinButton,
@@ -680,39 +681,6 @@
);
}
- onPressJoin = () => {
- void this.props.dispatchActionPromise(
- joinThreadActionTypes,
- this.joinAction(),
- );
- };
-
- async joinAction(): Promise<ThreadJoinPayload> {
- let joinThreadInput;
- if (this.props.rawThreadInfo.thick) {
- joinThreadInput = {
- thick: true,
- rawThreadInfo: this.props.rawThreadInfo,
- };
- } else {
- const query = this.props.calendarQuery();
- joinThreadInput = {
- thick: false,
- threadID: this.props.threadInfo.id,
- calendarQuery: {
- startDate: query.startDate,
- endDate: query.endDate,
- filters: [
- ...query.filters,
- { type: 'threads', threadIDs: [this.props.threadInfo.id] },
- ],
- },
- };
- }
-
- return await this.props.joinThread(joinThreadInput);
- }
-
showMediaGallery = () => {
const { keyboardState } = this.props;
invariant(keyboardState, 'keyboardState should be initialized');
@@ -776,7 +744,6 @@
const rawThreadInfo = useSelector(
state => state.threadStore.threadInfos[props.threadInfo.id],
);
- const callJoinThread = useJoinThread();
const { getChatMentionSearchIndex } = useChatMentionContext();
const chatMentionSearchIndex = getChatMentionSearchIndex(props.threadInfo);
@@ -1422,6 +1389,38 @@
};
}, [onNavigationBeforeRemove, onNavigationBlur, onNavigationFocus, props]);
+ const callJoinThread = useJoinThread();
+
+ const joinAction = React.useCallback(async (): Promise<ThreadJoinPayload> => {
+ let joinThreadInput;
+ if (rawThreadInfo.thick) {
+ joinThreadInput = {
+ thick: true,
+ rawThreadInfo: rawThreadInfo,
+ };
+ } else {
+ const query = calendarQuery();
+ joinThreadInput = {
+ thick: false,
+ threadID: props.threadInfo.id,
+ calendarQuery: {
+ startDate: query.startDate,
+ endDate: query.endDate,
+ filters: [
+ ...query.filters,
+ { type: 'threads', threadIDs: [props.threadInfo.id] },
+ ],
+ },
+ };
+ }
+
+ return await callJoinThread(joinThreadInput);
+ }, [calendarQuery, callJoinThread, props.threadInfo.id, rawThreadInfo]);
+
+ const onPressJoin = React.useCallback(() => {
+ void dispatchActionPromise(joinThreadActionTypes, joinAction());
+ }, [dispatchActionPromise, joinAction]);
+
return (
<ChatInputBar
{...props}
@@ -1478,6 +1477,7 @@
onSend={onSend}
isMessageEdited={isMessageEdited}
blockNavigation={blockNavigation}
+ onPressJoin={onPressJoin}
/>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 7:22 AM (10 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599772
Default Alt Text
D14015.diff (3 KB)
Attached To
Mode
D14015: [native] Move join thread functions in ChatInputBar to function component
Attached
Detach File
Event Timeline
Log In to Comment