Trivial Wikipedia URL for all taxa

This commit is contained in:
Ken-ichi Ueda
2024-03-14 17:13:47 -07:00
parent 1671ce20a1
commit 33a5ab2f39
3 changed files with 22 additions and 14 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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 (
<>
<Heading4 className="mb-3">{t( "WIKIPEDIA" )}</Heading4>
@@ -47,7 +63,7 @@ const Wikipedia = ( { taxon }: Props ): React.Node => {
baseStyle={baseStyle}
/>
)}
{ taxon.wikipedia_url && (
{ wikipediaUrl && (
<Body2
onPress={openWikipedia}
accessibilityRole="link"