From 2f4b3c15235c6a5225709ff8a9898e7d90f98211 Mon Sep 17 00:00:00 2001 From: Matthew Turk Date: Mon, 1 Jan 2024 12:48:32 -0600 Subject: [PATCH] Refactor `Byline` and `Section` for navigation --- components/common/Byline.jsx | 13 +++++++---- components/screens/Section.jsx | 41 ++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/components/common/Byline.jsx b/components/common/Byline.jsx index 285145e..5f32868 100644 --- a/components/common/Byline.jsx +++ b/components/common/Byline.jsx @@ -5,10 +5,15 @@ import { TouchableOpacity, StyleSheet, View } from "react-native"; import { Spacing, Sections } from "../../utils/constants"; +const includesDesks = (category) => { + return category.desks && Object.keys(category.desks).length > 0; +}; + export default function Byline({ authors, section, sourceName, category, date, navigation }) { const entries = Object.entries(authors); const bylineFontSize = entries.length < 3 ? 16 : 14; - const richCategory = Object.values(Sections).find((item) => item.id === category.id) ?? category; + const richCategory = Object.values(Sections).find((value) => value.id === category.id) ?? category; + const resolvedCategory = [3, 23, 25].includes(category.id) && includesDesks(richCategory) ? richCategory : category; const Name = ({ detail }) => ( navigation.navigate("Author", { name: detail[0], id: detail[1] })}> @@ -42,10 +47,10 @@ export default function Byline({ authors, section, sourceName, category, date, n