Skip to content

Commit

Permalink
fix: repair tags list on tabs (#2506)
Browse files Browse the repository at this point in the history
* fix: repair tags list on tabs

I've chosen to make it more restrictive than it was before since these features were broken anyway. plus adding arbritrary props here isn't the right level of customization for us moving forward

* fixed route params
  • Loading branch information
redreceipt committed May 17, 2022
1 parent 4739ad1 commit a060af5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
5 changes: 3 additions & 2 deletions packages/apollos-ui-connected/src/TabsConnected/Tabs.js
Expand Up @@ -87,12 +87,13 @@ const Tabs = ({ tabs }) => {
}, [client]);
const tabNavs = useMemo(
() =>
tabs.map(({ title, icon, feed }) => ({
tabs.map(({ title, icon, feed }, i) => ({
title,
icon,
component: createTab({
featureFeedId: feed.id,
options: {
headerLargeTitle: i !== 0,
...(ApollosConfig.TABS[title]?.showLogo
? { headerCenter: HeaderLogo }
: {}),
Expand All @@ -102,9 +103,9 @@ const Tabs = ({ tabs }) => {
...(ApollosConfig.TABS[title]?.showProfile
? { headerLeft: ProfileButton }
: {}),
...(ApollosConfig.TABS[title] ?? {}),
},
title,
showTags: ApollosConfig.TABS[title]?.showTags || false,
}),
})),
[tabs]
Expand Down
23 changes: 4 additions & 19 deletions packages/apollos-ui-connected/src/TabsConnected/createTab.js
Expand Up @@ -11,13 +11,13 @@ import FeaturesFeedConnected from '../FeaturesFeedConnected';
import ContentFeed from '../ContentFeedConnected';
import TagFilterConnected from '../TagFilterConnected';

const Tab = ({ useTagFilter, feedViewProps, additionalFeatures }) => {
const Tab = () => {
const navigation = useNavigation();
const route = useRoute();
const [filteredTags, setFilteredTags] = useState([]);
return (
<>
{useTagFilter ? (
{route.params.showTags ? (
<TagFilterConnected
filteredTags={filteredTags}
setFilteredTags={setFilteredTags}
Expand All @@ -30,8 +30,6 @@ const Tab = ({ useTagFilter, feedViewProps, additionalFeatures }) => {
openUrl={openUrl}
featureFeedId={route.params.featureFeedId}
navigation={navigation}
feedViewProps={feedViewProps}
additionalFeatures={additionalFeatures}
/>
</BackgroundView>
)}
Expand All @@ -40,33 +38,20 @@ const Tab = ({ useTagFilter, feedViewProps, additionalFeatures }) => {
);
};

Tab.propTypes = {
useTagFilter: PropTypes.bool,
feedViewProps: PropTypes.shape({}),
additionalFeatures: PropTypes.shape({}),
};

Tab.defaultProps = {
useTagFilter: false,
feedViewProps: {},
additionalFeatures: {},
};

export const createTab = ({ featureFeedId, title, screenOptions, options }) => {
export const createTab = ({ featureFeedId, title, options, showTags }) => {
const TabStack = createNativeStackNavigator();
const TabNav = () => (
<TabStack.Navigator
screenOptions={{
headerHideShadow: true,
headerLargeTitle: true,
...screenOptions,
}}
>
<TabStack.Screen
name={title}
component={Tab}
options={options}
initialParams={{ featureFeedId }}
initialParams={{ featureFeedId, showTags }}
/>
<TabStack.Screen
component={ContentFeed}
Expand Down
1 change: 1 addition & 0 deletions templates/mobile/theme.js
Expand Up @@ -30,6 +30,7 @@ const TABS = {
},
Read: {
showProfile: true,
showTags: true,
},
Watch: {
showProfile: true,
Expand Down

0 comments on commit a060af5

Please sign in to comment.