Skip to content

Commit a4fa893

Browse files
Fixes for coding standards (keeping Vir happy)
1 parent 8d1b4c2 commit a4fa893

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

src/components/MessageInput/InputButtons.tsx

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react';
22
import { StyleSheet, View } from 'react-native';
3+
34
import {
45
MessageInputContextValue,
56
useMessageInputContext,
6-
} from '../../contexts';
7+
} from '../../contexts/messageInputContext/MessageInputContext';
78
import { useTheme } from '../../contexts/themeContext/ThemeContext';
89

910
import type {
@@ -96,28 +97,26 @@ export const InputButtonsWithContext = <
9697
return null;
9798
}
9899

99-
return (
100+
return !showMoreOptions &&
101+
(hasImagePicker || hasFilePicker) &&
102+
hasCommands ? (
103+
<MoreOptionsButton handleOnPress={() => setShowMoreOptions(true)} />
104+
) : (
100105
<>
101-
{!showMoreOptions && (hasImagePicker || hasFilePicker) && hasCommands ? (
102-
<MoreOptionsButton handleOnPress={() => setShowMoreOptions(true)} />
103-
) : (
104-
<>
105-
{(hasImagePicker || hasFilePicker) && uploadsEnabled !== false && (
106-
<View
107-
style={[
108-
hasCommands ? styles.attachButtonContainer : undefined,
109-
attachButtonContainer,
110-
]}
111-
>
112-
<AttachButton handleOnPress={toggleAttachmentPicker} />
113-
</View>
114-
)}
115-
{hasCommands && !text && (
116-
<View style={commandsButtonContainer}>
117-
<CommandsButton handleOnPress={openCommandsPicker} />
118-
</View>
119-
)}
120-
</>
106+
{(hasImagePicker || hasFilePicker) && uploadsEnabled !== false && (
107+
<View
108+
style={[
109+
hasCommands ? styles.attachButtonContainer : undefined,
110+
attachButtonContainer,
111+
]}
112+
>
113+
<AttachButton handleOnPress={toggleAttachmentPicker} />
114+
</View>
115+
)}
116+
{hasCommands && !text && (
117+
<View style={commandsButtonContainer}>
118+
<CommandsButton handleOnPress={openCommandsPicker} />
119+
</View>
121120
)}
122121
</>
123122
);
@@ -134,30 +133,45 @@ const areEqual = <
134133
prevProps: InputButtonsWithContextProps<At, Ch, Co, Ev, Me, Re, Us>,
135134
nextProps: InputButtonsWithContextProps<At, Ch, Co, Ev, Me, Re, Us>,
136135
) => {
137-
if (prevProps.hasImagePicker !== nextProps.hasImagePicker) {
136+
const {
137+
hasCommands: prevHasCommands,
138+
hasFilePicker: prevHasFilePicker,
139+
hasImagePicker: prevHasImagePicker,
140+
showMoreOptions: prevShowMoreOptions,
141+
text: prevText,
142+
uploadsEnabled: prevUploadsEnabled,
143+
} = prevProps;
144+
145+
const {
146+
hasCommands: nextHasCommands,
147+
hasFilePicker: nextHasFilePicker,
148+
hasImagePicker: nextHasImagePicker,
149+
showMoreOptions: nextShowMoreOptions,
150+
text: nextText,
151+
uploadsEnabled: nextUploadsEnabled,
152+
} = nextProps;
153+
154+
if (prevHasImagePicker !== nextHasImagePicker) {
138155
return false;
139156
}
140157

141-
if (prevProps.hasFilePicker !== nextProps.hasFilePicker) {
158+
if (prevHasFilePicker !== nextHasFilePicker) {
142159
return false;
143160
}
144161

145-
if (prevProps.hasCommands !== nextProps.hasCommands) {
162+
if (prevHasCommands !== nextHasCommands) {
146163
return false;
147164
}
148165

149-
if (prevProps.uploadsEnabled !== nextProps.uploadsEnabled) {
166+
if (prevUploadsEnabled !== nextUploadsEnabled) {
150167
return false;
151168
}
152169

153-
if (prevProps.showMoreOptions !== nextProps.showMoreOptions) {
170+
if (prevShowMoreOptions !== nextShowMoreOptions) {
154171
return false;
155172
}
156173

157-
if (
158-
(!prevProps.text && nextProps.text) ||
159-
(prevProps.text && !nextProps.text)
160-
) {
174+
if ((!prevProps.text && nextText) || (prevText && !nextText)) {
161175
return false;
162176
}
163177

src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import type { AttachButtonProps } from '../../components/MessageInput/AttachButt
4646
import type { CommandsButtonProps } from '../../components/MessageInput/CommandsButton';
4747
import type { FileUploadPreviewProps } from '../../components/MessageInput/FileUploadPreview';
4848
import type { ImageUploadPreviewProps } from '../../components/MessageInput/ImageUploadPreview';
49-
import type { InputButtonsProps } from '../..//components/MessageInput/InputButtons';
49+
import type { InputButtonsProps } from '../../components/MessageInput/InputButtons';
5050
import type { MessageInputProps } from '../../components/MessageInput/MessageInput';
5151
import type { MoreOptionsButtonProps } from '../../components/MessageInput/MoreOptionsButton';
5252
import type { SendButtonProps } from '../../components/MessageInput/SendButton';

0 commit comments

Comments
 (0)