Page MenuHomePhabricator

D14015.id45956.diff
No OneTemporary

D14015.id45956.diff

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

Mime Type
text/plain
Expires
Sat, Nov 30, 5:30 AM (8 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599772
Default Alt Text
D14015.id45956.diff (3 KB)

Event Timeline