Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32153577
D10385.1765034873.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D10385.1765034873.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
@@ -64,6 +64,7 @@
draftKeyFromThreadID,
} from 'lib/shared/thread-utils.js';
import type { CalendarQuery } from 'lib/types/entry-types.js';
+import type { SetState } from 'lib/types/hook-types.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { PhotoPaste } from 'lib/types/media-types.js';
import { messageTypes } from 'lib/types/message-types-enum.js';
@@ -308,12 +309,13 @@
+navigation: ?ChatNavigationProp<'MessageList'>,
+overlayContext: ?OverlayContextType,
+messageEditingContext: ?MessageEditingContextType,
+ +selectionState: SyncedSelectionData,
+ +setSelectionState: SetState<SyncedSelectionData>,
};
type State = {
+text: string,
+textEdited: boolean,
+buttonsExpanded: boolean,
- +selectionState: SyncedSelectionData,
+isExitingDuringEditMode: boolean,
};
class ChatInputBar extends React.PureComponent<Props, State> {
@@ -342,7 +344,6 @@
text: props.draft,
textEdited: false,
buttonsExpanded: true,
- selectionState: { text: props.draft, selection: { start: 0, end: 0 } },
isExitingDuringEditMode: false,
};
@@ -671,8 +672,8 @@
}
const typeaheadRegexMatches = getTypeaheadRegexMatches(
- this.state.selectionState.text,
- this.state.selectionState.selection,
+ this.props.selectionState.text,
+ this.props.selectionState.selection,
nativeMentionTypeaheadRegex,
);
@@ -861,8 +862,8 @@
allowImagePasteForThreadID={this.props.threadInfo.id}
value={this.state.text}
onChangeText={this.updateText}
- selection={this.state.selectionState.selection}
- onUpdateSyncedSelectionData={this.updateSelectionState}
+ selection={this.props.selectionState.selection}
+ onUpdateSyncedSelectionData={this.props.setSelectionState}
placeholder="Send a message..."
placeholderTextColor={this.props.colors.listInputButton}
multiline={true}
@@ -920,10 +921,6 @@
this.saveDraft(text);
};
- updateSelectionState: (data: SyncedSelectionData) => void = data => {
- this.setState({ selectionState: data });
- };
-
saveDraft: (text: string) => void = _throttle(text => {
this.props.dispatch({
type: updateDraftActionType,
@@ -939,8 +936,8 @@
this.setState({
text,
textEdited: true,
- selectionState: { text, selection },
});
+ this.props.setSelectionState({ text, selection });
this.saveDraft(text);
this.focusAndUpdateButtonsVisibility();
@@ -1308,6 +1305,12 @@
);
const editMessage = useEditMessage();
+ const [selectionState, setSelectionState] =
+ React.useState<SyncedSelectionData>({
+ text: draft,
+ selection: { start: 0, end: 0 },
+ });
+
return (
<ChatInputBar
{...props}
@@ -1337,6 +1340,8 @@
navigation={props.navigation}
overlayContext={overlayContext}
messageEditingContext={messageEditingContext}
+ selectionState={selectionState}
+ setSelectionState={setSelectionState}
/>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 3:27 PM (17 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5839153
Default Alt Text
D10385.1765034873.diff (3 KB)
Attached To
Mode
D10385: [native] Lift selectionState in chat input bar
Attached
Detach File
Event Timeline
Log In to Comment