From 43aeb62d57cb0e38b1d02f4f6a91d1b9c6db3d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnea=20R=C3=BAn=20Vignisd=C3=B3ttir?= Date: Mon, 10 Aug 2020 13:19:22 +0000 Subject: [PATCH 1/2] add null checks and fallback to covid.is link if no read more link is provided --- .../Announcements/Announcements.tsx | 68 ++++++++++--------- src/router/logged-in/screens/HomeScreen.tsx | 4 +- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/components/Announcements/Announcements.tsx b/src/components/Announcements/Announcements.tsx index e810ce5..a7e0e8f 100644 --- a/src/components/Announcements/Announcements.tsx +++ b/src/components/Announcements/Announcements.tsx @@ -105,38 +105,42 @@ const Announcements = ({ activeOpacity={1} accessibilityElementHidden={index !== i} > - - {title} - - {subtitle} - ${description}`} - allowFontScaling - baseFontStyle={textStyles} - containerStyle={{ - padding: 0, - flexDirection: 'row', - alignItems: 'flex-start', - }} - tagsStyles={{ - a: { - ...textStyles, - textDecorationLine: 'none', - }, - }} - renderers={{ - div: (_, children, convertedCSSStyles, passProps) => ( - - {children} - - ), - }} - ignoredTags={[...IGNORED_TAGS, 'img', 'br']} - /> + {title && ( + + {title} + + )} + {subtitle && {subtitle}} + {description && ( + ${description}`} + allowFontScaling + baseFontStyle={textStyles} + containerStyle={{ + padding: 0, + flexDirection: 'row', + alignItems: 'flex-start', + }} + tagsStyles={{ + a: { + ...textStyles, + textDecorationLine: 'none', + }, + }} + renderers={{ + div: (_, children, convertedCSSStyles, passProps) => ( + + {children} + + ), + }} + ignoredTags={[...IGNORED_TAGS, 'img', 'br']} + /> + )} ))} diff --git a/src/router/logged-in/screens/HomeScreen.tsx b/src/router/logged-in/screens/HomeScreen.tsx index bc08e80..15f93f7 100644 --- a/src/router/logged-in/screens/HomeScreen.tsx +++ b/src/router/logged-in/screens/HomeScreen.tsx @@ -171,8 +171,8 @@ const HomeScreen = ({ navigation }) => { ? cur['meginmal'] : cur['meginmal-ensku'], link: inIcelandic - ? cur['linkur-a-frett'] - : cur['read-more-hlekkur-ensku'], + ? cur['linkur-a-frett'] || t('covidLink') + : cur['read-more-hlekkur-ensku'] || t('covidLink'), }, ]; }, []), From 361e3c23b816b26c70d721de147108bbf4dbe054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnea=20R=C3=BAn=20Vignisd=C3=B3ttir?= Date: Mon, 10 Aug 2020 13:22:06 +0000 Subject: [PATCH 2/2] use announcementsLink instead og covidLink --- src/router/logged-in/screens/HomeScreen.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/router/logged-in/screens/HomeScreen.tsx b/src/router/logged-in/screens/HomeScreen.tsx index 15f93f7..4b36880 100644 --- a/src/router/logged-in/screens/HomeScreen.tsx +++ b/src/router/logged-in/screens/HomeScreen.tsx @@ -171,8 +171,8 @@ const HomeScreen = ({ navigation }) => { ? cur['meginmal'] : cur['meginmal-ensku'], link: inIcelandic - ? cur['linkur-a-frett'] || t('covidLink') - : cur['read-more-hlekkur-ensku'] || t('covidLink'), + ? cur['linkur-a-frett'] || t('announcementsLink') + : cur['read-more-hlekkur-ensku'] || t('announcementsLink'), }, ]; }, []),