1- import { useNavigation } from '@react-navigation/native' ;
1+ import { useNavigation } from '@react-navigation/native' ;
22import React , { useEffect , useMemo } from 'react' ;
33import { FlatList , StyleSheet , View } from 'react-native' ;
44import { useDispatch , useSelector } from 'react-redux' ;
@@ -30,29 +30,29 @@ interface IStatus {
3030 _id : string ;
3131 name : string ;
3232 statusType : TUserStatus ;
33- isCustom ?: boolean ;
33+ isCustom ?: boolean ;
3434}
3535
3636const STATUS : IStatus [ ] = [
3737 {
3838 _id : 'online' ,
3939 name : 'Online' ,
40- statusType : 'online'
40+ statusType : 'online'
4141 } ,
4242 {
4343 _id : 'busy' ,
4444 name : 'Busy' ,
45- statusType : 'busy'
45+ statusType : 'busy'
4646 } ,
4747 {
4848 _id : 'away' ,
4949 name : 'Away' ,
50- statusType : 'away'
50+ statusType : 'away'
5151 } ,
5252 {
5353 _id : 'offline' ,
5454 name : 'Offline' ,
55- statusType : 'offline'
55+ statusType : 'offline'
5656 }
5757] ;
5858
@@ -79,14 +79,14 @@ const Status = ({
7979 statusText,
8080 setStatus,
8181 isCustom,
82- isCustomSelected
82+ isCustomSelected
8383} : {
8484 statusType : IStatus ;
8585 status : TUserStatus ;
8686 statusText : string ;
8787 setStatus : ( status : TUserStatus , statusText : string ) => void ;
8888 isCustom ?: boolean ;
89- isCustomSelected : boolean ;
89+ isCustomSelected : boolean ;
9090} ) => {
9191 const { _id, name } = statusType ;
9292 const acessibilityLabel = useMemo ( ( ) => {
@@ -103,11 +103,10 @@ const Status = ({
103103 if ( isCustomSelected ) {
104104 return statusText === name ;
105105 }
106-
106+
107107 return status === statusType . _id ;
108108 } , [ statusText , name , status , statusType ] ) ;
109109
110-
111110 return (
112111 < >
113112 < List . Item
@@ -130,7 +129,6 @@ const Status = ({
130129 ) ;
131130} ;
132131
133-
134132const StatusView = ( ) : React . ReactElement => {
135133 const validationSchema = yup . object ( ) . shape ( {
136134 statusText : yup
@@ -143,7 +141,7 @@ const StatusView = (): React.ReactElement => {
143141 const Accounts_AllowInvisibleStatusOption = useSelector (
144142 ( state : IApplicationState ) => state . settings . Accounts_AllowInvisibleStatusOption
145143 ) ;
146- const customUserStatus = useSelector ( ( state : IApplicationState ) => state . customUserStatus ) ;
144+ const customUserStatus = useSelector ( ( state : IApplicationState ) => state . customUserStatus ) ;
147145
148146 const {
149147 control,
@@ -186,9 +184,9 @@ const StatusView = (): React.ReactElement => {
186184
187185 const setStatus = ( status : TUserStatus , statusText : string ) => {
188186 setValue ( 'status' , status ) ;
189- if ( statusText ) {
190- setValue ( 'statusText' , statusText ) ;
191- }
187+ if ( statusText ) {
188+ setValue ( 'statusText' , statusText ) ;
189+ }
192190 } ;
193191
194192 const setCustomStatus = async ( status : TUserStatus , statusText : string ) => {
@@ -210,12 +208,15 @@ const StatusView = (): React.ReactElement => {
210208 sendLoadingEvent ( { visible : false } ) ;
211209 } ;
212210
213- const AllStatus = [ ...STATUS , ...customUserStatus . map ( s => ( { ...s , isCustom : true } ) ) ] ;
211+ const AllStatus = [ ...STATUS , ...customUserStatus . map ( s => ( { ...s , isCustom : true } ) ) ] ;
214212 const statusType = Accounts_AllowInvisibleStatusOption ? AllStatus : AllStatus . filter ( s => s . _id !== 'offline' ) ;
215213
216- const isCustomSelected = useMemo ( ( ) => ! ! customUserStatus . find ( s => s . statusType === inputValues . status && s . name === inputValues . statusText ) , [ inputValues . status , inputValues . statusText , statusType ] ) ;
217-
218- const isStatusChanged = ( ) => {
214+ const isCustomSelected = useMemo (
215+ ( ) => ! ! customUserStatus . find ( s => s . statusType === inputValues . status && s . name === inputValues . statusText ) ,
216+ [ inputValues . status , inputValues . statusText , statusType ]
217+ ) ;
218+
219+ const isStatusChanged = ( ) => {
219220 const { status } = inputValues ;
220221 if ( ! isValid ) {
221222 return true ;
@@ -236,7 +237,16 @@ const StatusView = (): React.ReactElement => {
236237 < FlatList
237238 data = { statusType }
238239 keyExtractor = { item => item . _id }
239- renderItem = { ( { item } ) => < Status statusType = { item } statusText = { inputValues . statusText } status = { inputValues . status } setStatus = { setStatus } isCustom = { item . isCustom } isCustomSelected = { isCustomSelected } /> }
240+ renderItem = { ( { item } ) => (
241+ < Status
242+ statusType = { item }
243+ statusText = { inputValues . statusText }
244+ status = { inputValues . status }
245+ setStatus = { setStatus }
246+ isCustom = { item . isCustom }
247+ isCustomSelected = { isCustomSelected }
248+ />
249+ ) }
240250 ListHeaderComponent = {
241251 < >
242252 < ControlledFormTextInput
0 commit comments