From 33a5ab2f39aa38b281d17c33e22225a686cf4dda Mon Sep 17 00:00:00 2001 From: Ken-ichi Ueda Date: Thu, 14 Mar 2024 17:13:47 -0700 Subject: [PATCH] Trivial Wikipedia URL for all taxa --- ios/Podfile.lock | 4 ++-- .../project.pbxproj | 12 ++--------- src/components/TaxonDetails/Wikipedia.js | 20 +++++++++++++++++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index a6d7e6745..b3fc328aa 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -727,7 +727,7 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/yoga" SPEC CHECKSUMS: - boost: 57d2868c099736d80fcd648bf211b4431e51a558 + boost: 7dcd2de282d72e344012f7d6564d024930a6a440 BVLinearGradient: 880f91a7854faff2df62518f0281afb1c60d49a3 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: 9840513ec2766e31fb9e34c2dabb2c4671400fcd @@ -810,4 +810,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 77ed9526d4011b245ce5afa1ea331dea4c67d753 -COCOAPODS: 1.14.2 +COCOAPODS: 1.14.3 diff --git a/ios/iNaturalistReactNative.xcodeproj/project.pbxproj b/ios/iNaturalistReactNative.xcodeproj/project.pbxproj index d300361c2..e76ff8171 100644 --- a/ios/iNaturalistReactNative.xcodeproj/project.pbxproj +++ b/ios/iNaturalistReactNative.xcodeproj/project.pbxproj @@ -979,11 +979,7 @@ "-DFOLLY_MOBILE=1", "-DFOLLY_USE_LIBCPP=1", ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-Wl", - "-ld_classic", - ); + OTHER_LDFLAGS = "$(inherited)"; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; }; @@ -1052,11 +1048,7 @@ "-DFOLLY_MOBILE=1", "-DFOLLY_USE_LIBCPP=1", ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-Wl", - "-ld_classic", - ); + OTHER_LDFLAGS = "$(inherited)"; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; diff --git a/src/components/TaxonDetails/Wikipedia.js b/src/components/TaxonDetails/Wikipedia.js index 807a036f0..dfa4423e3 100644 --- a/src/components/TaxonDetails/Wikipedia.js +++ b/src/components/TaxonDetails/Wikipedia.js @@ -19,7 +19,8 @@ type Props = { const Wikipedia = ( { taxon }: Props ): React.Node => { const { width } = useWindowDimensions(); - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); + const { language } = i18n; const openWikipedia = ( ) => { if ( taxon?.wikipedia_url ) { @@ -36,6 +37,21 @@ const Wikipedia = ( { taxon }: Props ): React.Node => { }; const fonts = ["Whitney-Light", "Whitney-Light-Pro", ...defaultSystemFonts]; + let wikipediaUrl = taxon.wikipedia_url; + + // Trivial fallback that will suffer from all the same problems we've had + // doing the same thing on the web. Instead we should use the + // taxa/:id/describe endpoint to retrieve a description and a URL like we + // do on the web + if ( !wikipediaUrl ) { + const lang = language?.split( "-" )?.[0] || "en"; + wikipediaUrl = `https://${lang}.wikipedia.org/wiki/${taxon.name}`; + } + + if ( !taxon.wikipedia_summary || taxon.wikipedia_summary.length === 0 ) { + return null; + } + return ( <> {t( "WIKIPEDIA" )} @@ -47,7 +63,7 @@ const Wikipedia = ( { taxon }: Props ): React.Node => { baseStyle={baseStyle} /> )} - { taxon.wikipedia_url && ( + { wikipediaUrl && (