Skip to content

Commit 2ae81e9

Browse files
committed
fix: code clean up
1 parent 5648653 commit 2ae81e9

File tree

8 files changed

+65
-228
lines changed

8 files changed

+65
-228
lines changed

package/src/components/AutoCompleteInput/AutoCompleteInput.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { useStateStore } from '../../hooks/useStateStore';
2727
type AutoCompleteInputPropsWithContext = TextInputProps &
2828
Pick<
2929
MessageInputContextValue,
30-
'isCommandUIEnabled' | 'maxMessageLength' | 'numberOfLines' | 'onChangeText' | 'setInputBoxRef'
30+
'maxMessageLength' | 'numberOfLines' | 'onChangeText' | 'setInputBoxRef'
3131
> &
3232
Pick<TranslationContextValue, 't'> & {
3333
/**
@@ -166,21 +166,13 @@ const MemoizedAutoCompleteInput = React.memo(
166166
) as typeof AutoCompleteInputWithContext;
167167

168168
export const AutoCompleteInput = (props: AutoCompleteInputProps) => {
169-
const {
170-
isCommandUIEnabled,
171-
additionalTextInputProps,
172-
maxMessageLength,
173-
numberOfLines,
174-
onChangeText,
175-
setInputBoxRef,
176-
} = useMessageInputContext();
169+
const { maxMessageLength, numberOfLines, onChangeText, setInputBoxRef } =
170+
useMessageInputContext();
177171
const { t } = useTranslationContext();
178172

179173
return (
180174
<MemoizedAutoCompleteInput
181175
{...{
182-
additionalTextInputProps,
183-
isCommandUIEnabled,
184176
maxMessageLength,
185177
numberOfLines,
186178
onChangeText,

package/src/components/Channel/Channel.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,9 +1725,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
17251725
hideStickyDateHeader,
17261726
highlightedMessageId,
17271727
isChannelActive: shouldSyncChannel,
1728-
isCommandUIEnabled:
1729-
isCommandUIEnabled ??
1730-
!!(clientChannelConfig?.commands || [])?.some((command) => command.name === 'giphy'),
1728+
isCommandUIEnabled: isCommandUIEnabled ?? !!clientChannelConfig?.commands?.length,
17311729
lastRead,
17321730
loadChannelAroundMessage,
17331731
loadChannelAtFirstUnreadMessage,

package/src/components/MessageInput/InputButtons.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import { useOwnCapabilitiesContext } from '../../contexts/ownCapabilitiesContext
1212
import { useTheme } from '../../contexts/themeContext/ThemeContext';
1313
import { useStateStore } from '../../hooks/useStateStore';
1414

15-
const styles = StyleSheet.create({
16-
attachButtonContainer: { paddingRight: 5 },
17-
});
18-
1915
export type InputButtonsProps = Partial<InputButtonsWithContextProps>;
2016

2117
export type InputButtonsWithContextProps = Pick<
@@ -28,13 +24,10 @@ export type InputButtonsWithContextProps = Pick<
2824
| 'hasImagePicker'
2925
| 'MoreOptionsButton'
3026
| 'selectedPicker'
31-
| 'setShowMoreOptions'
32-
| 'showMoreOptions'
3327
| 'toggleAttachmentPicker'
3428
>;
3529

3630
const textComposerStateSelector = (state: TextComposerState) => ({
37-
suggestions: state.suggestions,
3831
text: state.text,
3932
});
4033

@@ -107,7 +100,6 @@ const areEqual = (
107100
hasFilePicker: prevHasFilePicker,
108101
hasImagePicker: prevHasImagePicker,
109102
selectedPicker: prevSelectedPicker,
110-
showMoreOptions: prevShowMoreOptions,
111103
} = prevProps;
112104

113105
const {
@@ -116,7 +108,6 @@ const areEqual = (
116108
hasFilePicker: nextHasFilePicker,
117109
hasImagePicker: nextHasImagePicker,
118110
selectedPicker: nextSelectedPicker,
119-
showMoreOptions: nextShowMoreOptions,
120111
} = nextProps;
121112

122113
if (prevHasCameraPicker !== nextHasCameraPicker) {
@@ -139,10 +130,6 @@ const areEqual = (
139130
return false;
140131
}
141132

142-
if (prevShowMoreOptions !== nextShowMoreOptions) {
143-
return false;
144-
}
145-
146133
return true;
147134
};
148135

@@ -161,8 +148,6 @@ export const InputButtons = (props: InputButtonsProps) => {
161148
hasImagePicker,
162149
MoreOptionsButton,
163150
selectedPicker,
164-
setShowMoreOptions,
165-
showMoreOptions,
166151
toggleAttachmentPicker,
167152
} = useMessageInputContext();
168153

@@ -177,11 +162,13 @@ export const InputButtons = (props: InputButtonsProps) => {
177162
hasImagePicker,
178163
MoreOptionsButton,
179164
selectedPicker,
180-
setShowMoreOptions,
181-
showMoreOptions,
182165
toggleAttachmentPicker,
183166
}}
184167
{...props}
185168
/>
186169
);
187170
};
171+
172+
const styles = StyleSheet.create({
173+
attachButtonContainer: { paddingRight: 5 },
174+
});

package/src/components/MessageInput/components/CommandInput.tsx

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
2+
import { Pressable, StyleSheet, Text, View } from 'react-native';
33

44
import { CustomDataManagerState } from 'stream-chat';
55

@@ -16,27 +16,6 @@ import { CircleClose, GiphyLightning } from '../../../icons';
1616
import { AutoCompleteInput } from '../../AutoCompleteInput/AutoCompleteInput';
1717
import { useCountdown } from '../hooks/useCountdown';
1818

19-
const styles = StyleSheet.create({
20-
autoCompleteInputContainer: {
21-
alignItems: 'center',
22-
flexDirection: 'row',
23-
paddingLeft: 8,
24-
paddingRight: 10,
25-
},
26-
giphyContainer: {
27-
alignItems: 'center',
28-
borderRadius: 12,
29-
flexDirection: 'row',
30-
marginRight: 8,
31-
paddingHorizontal: 8,
32-
paddingVertical: 4,
33-
},
34-
giphyText: {
35-
fontSize: 12,
36-
fontWeight: 'bold',
37-
},
38-
});
39-
4019
export type CommandInputProps = Partial<
4120
Pick<
4221
MessageInputContextValue,
@@ -71,7 +50,7 @@ export const CommandInput = ({
7150
colors: { accent_blue, grey, white },
7251
messageInput: {
7352
autoCompleteInputContainer,
74-
giphyCommandInput: { giphyContainer, giphyText },
53+
commandInput: { closeButton, container, text },
7554
},
7655
},
7756
} = useTheme();
@@ -82,25 +61,56 @@ export const CommandInput = ({
8261
setShowMoreOptions(true);
8362
};
8463

64+
if (!command) {
65+
return null;
66+
}
67+
8568
return (
8669
<View style={[styles.autoCompleteInputContainer, autoCompleteInputContainer]}>
87-
{command ? (
88-
<View style={[styles.giphyContainer, { backgroundColor: accent_blue }, giphyContainer]}>
89-
<GiphyLightning fill={white} size={16} />
90-
<Text style={[styles.giphyText, { color: white }, giphyText]}>
91-
{command.toUpperCase()}
92-
</Text>
93-
</View>
94-
) : null}
70+
<View style={[styles.giphyContainer, { backgroundColor: accent_blue }, container]}>
71+
<GiphyLightning fill={white} size={16} />
72+
<Text style={[styles.giphyText, { color: white }, text]}>{command.toUpperCase()}</Text>
73+
</View>
9574

9675
<AutoCompleteInput cooldownActive={!!cooldownRemainingSeconds} />
97-
{command ? (
98-
<TouchableOpacity disabled={disabled} onPress={onCloseHandler} testID='close-button'>
99-
<CircleClose height={20} pathFill={grey} width={20} />
100-
</TouchableOpacity>
101-
) : null}
76+
<Pressable
77+
disabled={disabled}
78+
onPress={onCloseHandler}
79+
style={({ pressed }) => {
80+
return [
81+
{
82+
opacity: pressed ? 0.8 : 1,
83+
},
84+
closeButton,
85+
];
86+
}}
87+
testID='close-button'
88+
>
89+
<CircleClose height={20} pathFill={grey} width={20} />
90+
</Pressable>
10291
</View>
10392
);
10493
};
10594

10695
CommandInput.displayName = 'CommandInput{messageInput}';
96+
97+
const styles = StyleSheet.create({
98+
autoCompleteInputContainer: {
99+
alignItems: 'center',
100+
flexDirection: 'row',
101+
paddingLeft: 8,
102+
paddingRight: 10,
103+
},
104+
giphyContainer: {
105+
alignItems: 'center',
106+
borderRadius: 12,
107+
flexDirection: 'row',
108+
marginRight: 8,
109+
paddingHorizontal: 8,
110+
paddingVertical: 4,
111+
},
112+
giphyText: {
113+
fontSize: 12,
114+
fontWeight: 'bold',
115+
},
116+
});

package/src/contexts/themeContext/utils/theme.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ export type Theme = {
307307
waveform: ViewStyle;
308308
};
309309
autoCompleteInputContainer: ViewStyle;
310+
commandInput: {
311+
closeButton: ViewStyle;
312+
container: ViewStyle;
313+
text: TextStyle;
314+
};
310315
commandsButton: ViewStyle;
311316
commandsButtonContainer: ViewStyle;
312317
composerContainer: ViewStyle;
@@ -331,10 +336,7 @@ export type Theme = {
331336
flatList: ViewStyle;
332337
};
333338
focusedInputBoxContainer: ViewStyle;
334-
giphyCommandInput: {
335-
giphyContainer: ViewStyle;
336-
giphyText: TextStyle;
337-
};
339+
338340
imageUploadPreview: {
339341
dismiss: ViewStyle;
340342
dismissIconColor: ColorValue;
@@ -1072,6 +1074,11 @@ export const defaultTheme: Theme = {
10721074
},
10731075
audioRecordingWaveform: { container: {}, waveform: {} },
10741076
autoCompleteInputContainer: {},
1077+
commandInput: {
1078+
closeButton: {},
1079+
container: {},
1080+
text: {},
1081+
},
10751082
commandsButton: {},
10761083
commandsButtonContainer: {},
10771084
composerContainer: {},
@@ -1096,10 +1103,6 @@ export const defaultTheme: Theme = {
10961103
flatList: {},
10971104
},
10981105
focusedInputBoxContainer: {},
1099-
giphyCommandInput: {
1100-
giphyContainer: {},
1101-
giphyText: {},
1102-
},
11031106
imageUploadPreview: {
11041107
dismiss: {},
11051108
dismissIconColor: '',

package/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export * from './types/types';
1313

1414
export * from './utils/patchMessageTextCommand';
1515
export * from './utils/i18n/Streami18n';
16-
export * from './utils/queryMembers';
17-
export * from './utils/queryUsers';
1816
export * from './utils/utils';
1917

2018
export { default as enTranslations } from './i18n/en.json';

package/src/utils/queryMembers.ts

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

0 commit comments

Comments
 (0)