11import React from 'react' ;
22import { StyleSheet , View } from 'react-native' ;
3+
34import {
45 MessageInputContextValue ,
56 useMessageInputContext ,
6- } from '../../contexts' ;
7+ } from '../../contexts/messageInputContext/MessageInputContext ' ;
78import { useTheme } from '../../contexts/themeContext/ThemeContext' ;
89
910import 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
0 commit comments