@@ -182,15 +182,15 @@ class GuiPluginList extends React.PureComponent<Props, State> {
182182 this . componentMounted = true
183183 }
184184
185- async componentDidMount ( ) {
185+ componentDidMount ( ) : void {
186186 this . updatePlugins ( )
187187 const { developerPluginUri } = getDeviceSettings ( )
188188 if ( developerPluginUri != null ) {
189189 this . setState ( { developerUri : developerPluginUri } )
190190 }
191191 }
192192
193- componentWillUnmount ( ) {
193+ componentWillUnmount ( ) : void {
194194 this . componentMounted = false
195195 if ( this . timeoutId != null ) clearTimeout ( this . timeoutId )
196196 }
@@ -206,7 +206,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
206206 }
207207 }
208208
209- updatePlugins ( ) {
209+ updatePlugins ( ) : void {
210210 // Create new array objects so we aren't patching the original JSON
211211 const currentPlugins : BuySellPlugins = {
212212 buy : [ ...( buySellPlugins . buy ?? [ ] ) ] ,
@@ -225,9 +225,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
225225 continue
226226 }
227227 const currentDirection = currentPlugins [ direction ] ?? [ ]
228- if ( currentPlugins [ direction ] == null ) {
229- currentPlugins [ direction ] = currentDirection
230- }
228+ currentPlugins [ direction ] ??= currentDirection
231229 for ( const patch of patches ) {
232230 // Skip comment rows
233231 if ( typeof patch === 'string' ) continue
@@ -268,7 +266,10 @@ class GuiPluginList extends React.PureComponent<Props, State> {
268266 /**
269267 * Launch the provided plugin, including pre-flight checks.
270268 */
271- async openPlugin ( listRow : GuiPluginRow , longPress : boolean = false ) {
269+ async openPlugin (
270+ listRow : GuiPluginRow ,
271+ longPress : boolean = false
272+ ) : Promise < void > {
272273 const {
273274 account,
274275 accountReferral,
@@ -318,9 +319,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
318319 this . setState ( { developerUri : deepPath } )
319320
320321 // Write to disk lazily:
321- writeDeveloperPluginUri ( deepPath ) . catch ( error => {
322- showError ( error )
323- } )
322+ writeDeveloperPluginUri ( deepPath ) . catch ( showError )
324323 }
325324 }
326325 if ( plugin . nativePlugin != null ) {
@@ -387,7 +386,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
387386 onPluginOpened ( )
388387 }
389388
390- renderTitle = ( guiPluginRow : GuiPluginRow ) => {
389+ renderTitle = ( guiPluginRow : GuiPluginRow ) : React . ReactElement => {
391390 const styles = getStyles ( this . props . theme )
392391 const { title, customTitleKey } = guiPluginRow
393392
@@ -426,22 +425,22 @@ class GuiPluginList extends React.PureComponent<Props, State> {
426425 ) ( error )
427426 if ( regionError != null && regionError . length > 0 ) {
428427 const country = COUNTRY_CODES . find ( c => c [ 'alpha-2' ] === countryCode )
429- const countryName = country ? country . name : countryCode // Fallback to countryCode if not found
428+ const countryName = country != null ? country . name : countryCode // Fallback to countryCode if not found
430429
431430 // Attempt to find the stateProvince name if stateProvinceCode is provided
432431 let stateProvinceName = stateProvinceCode
433- if ( country ?. stateProvinces && stateProvinceCode ) {
432+ if ( country ?. stateProvinces != null && stateProvinceCode != null ) {
434433 const stateProvince = country . stateProvinces . find (
435434 sp => sp [ 'alpha-2' ] === stateProvinceCode
436435 )
437- stateProvinceName = stateProvince
438- ? stateProvince . name
439- : stateProvinceCode // Fallback to stateProvinceCode if not found
436+ stateProvinceName =
437+ stateProvince != null ? stateProvince . name : stateProvinceCode // Fallback to stateProvinceCode if not found
440438 }
441439
442- const text = stateProvinceName
443- ? `${ stateProvinceName } , ${ countryName } `
444- : countryName
440+ const text =
441+ stateProvinceName != null
442+ ? `${ stateProvinceName } , ${ countryName } `
443+ : countryName
445444 Airship . show < 'ok' | undefined > ( bridge => (
446445 < ButtonsModal
447446 bridge = { bridge }
@@ -454,7 +453,10 @@ class GuiPluginList extends React.PureComponent<Props, State> {
454453 }
455454 }
456455
457- renderPlugin = ( { item, index } : ListRenderItemInfo < GuiPluginRow > ) => {
456+ renderPlugin = ( {
457+ item,
458+ index
459+ } : ListRenderItemInfo < GuiPluginRow > ) : React . ReactElement | null => {
458460 const { theme } = this . props
459461 const { pluginId } = item
460462 const plugin = guiPlugins [ pluginId ]
@@ -470,9 +472,10 @@ class GuiPluginList extends React.PureComponent<Props, State> {
470472 ? undefined
471473 : {
472474 displayName : poweredBy ,
473- icon : partnerLogoThemeKey
474- ? theme [ partnerLogoThemeKey ]
475- : { uri : getPartnerIconUri ( item . partnerIconPath ?? '' ) }
475+ icon :
476+ partnerLogoThemeKey != null
477+ ? theme [ partnerLogoThemeKey ]
478+ : { uri : getPartnerIconUri ( item . partnerIconPath ?? '' ) }
476479 }
477480 const [ totalAmount , settlementTime ] = item . description . split ( '\n' )
478481 return (
@@ -482,7 +485,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
482485 >
483486 < PaymentOptionCard
484487 title = { this . renderTitle ( item ) }
485- // @ts -expect-error
488+ // @ts -expect-error - we can assume paymentTypeLogoKey exists within paymentTypeLogosById because it comes from static JSON
486489 icon = { theme [ paymentTypeLogosById [ item . paymentTypeLogoKey ] ] }
487490 totalAmount = { totalAmount }
488491 settlementTime = { settlementTime }
@@ -491,9 +494,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
491494 await this . openPlugin ( item )
492495 } }
493496 onLongPress = { async ( ) => {
494- await this . openPlugin ( item , true ) . catch ( error => {
495- this . handleError ( error )
496- } )
497+ await this . openPlugin ( item , true ) . catch ( this . handleError )
497498 } }
498499 onProviderPress = { async ( ) => {
499500 await this . openPlugin ( item )
@@ -503,7 +504,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
503504 )
504505 }
505506
506- renderTop = ( ) => {
507+ renderTop = ( ) : React . ReactElement => {
507508 const {
508509 account,
509510 countryCode,
@@ -521,7 +522,9 @@ class GuiPluginList extends React.PureComponent<Props, State> {
521522 sp => sp [ 'alpha-2' ] === stateProvinceCode
522523 )
523524 const uri = `${ FLAG_LOGO_URL } /${
524- countryData ?. filename || countryData ?. name . toLowerCase ( ) . replace ( ' ' , '-' )
525+ countryData ?. filename ??
526+ countryData ?. name . toLowerCase ( ) . replace ( ' ' , '-' ) ??
527+ ''
525528 } .png`
526529 const hasCountryData = countryData != null
527530
@@ -601,7 +604,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
601604 )
602605 }
603606
604- renderEmptyList = ( ) => {
607+ renderEmptyList = ( ) : React . ReactElement | null => {
605608 const { countryCode, theme } = this . props
606609 const styles = getStyles ( theme )
607610 if ( countryCode === '' ) return null
@@ -615,7 +618,7 @@ class GuiPluginList extends React.PureComponent<Props, State> {
615618 )
616619 }
617620
618- render ( ) {
621+ render ( ) : React . ReactElement {
619622 const {
620623 accountPlugins,
621624 accountReferral,
@@ -823,9 +826,9 @@ const GuiPluginListSceneComponent = React.memo((props: OwnProps) => {
823826} )
824827
825828// Export separate components for buy and sell routes
826- export const BuyScene = ( props : BuyProps ) => (
829+ export const BuyScene = ( props : BuyProps ) : React . ReactElement => (
827830 < GuiPluginListSceneComponent { ...props } />
828831)
829- export const SellScene = ( props : SellProps ) => (
832+ export const SellScene = ( props : SellProps ) : React . ReactElement => (
830833 < GuiPluginListSceneComponent { ...props } />
831834)
0 commit comments