diff --git a/src/components/basicUIElements/view/tag/tagContainer.js b/src/components/basicUIElements/view/tag/tagContainer.js index 38bbadeba..5544db37a 100644 --- a/src/components/basicUIElements/view/tag/tagContainer.js +++ b/src/components/basicUIElements/view/tag/tagContainer.js @@ -25,6 +25,7 @@ class TagContainer extends PureComponent { this.state = { label: props.value, + isCommunity: false, }; } // Component Life Cycle Functions @@ -35,6 +36,7 @@ class TagContainer extends PureComponent { .then((r) => { this.setState({ label: r, + isCommunity: value !== r, }); return r; }) @@ -43,12 +45,13 @@ class TagContainer extends PureComponent { // Component Functions _handleOnTagPress = () => { const { navigation, onPress, value } = this.props; + const { isCommunity } = this.state; if (onPress) { onPress(); } else { navigation.navigate({ - routeName: ROUTES.SCREENS.TAG_RESULT, + routeName: isCommunity ? ROUTES.SCREENS.COMMUNITY : ROUTES.SCREENS.TAG_RESULT, params: { tag: value, }, diff --git a/src/screens/community/container/communityContainer.js b/src/screens/community/container/communityContainer.js index a7394f0d4..41016ef8b 100644 --- a/src/screens/community/container/communityContainer.js +++ b/src/screens/community/container/communityContainer.js @@ -8,7 +8,7 @@ import { subscribeCommunity } from '../../../providers/steem/dsteem'; import ROUTES from '../../../constants/routeNames'; -const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) => { +const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isLoggedIn }) => { const [data, setData] = useState(null); const [isSubscribed, setIsSubscribed] = useState(false); const tag = get(navigation, 'state.params.tag'); @@ -22,8 +22,10 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) = useEffect(() => { if (data) { getSubscriptions(currentAccount.username).then((result) => { - const _isSubscribed = result.some((item) => item[0] === data.name); - setIsSubscribed(_isSubscribed); + if (result) { + const _isSubscribed = result.some((item) => item[0] === data.name); + setIsSubscribed(_isSubscribed); + } }); } }, [data]); @@ -54,7 +56,8 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) = data, handleSubscribeButtonPress: _handleSubscribeButtonPress, handleNewPostButtonPress: _handleNewPostButtonPress, - isSubscribed: isSubscribed, + isSubscribed, + isLoggedIn, }) ); }; @@ -62,6 +65,7 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) = const mapStateToProps = (state) => ({ currentAccount: state.account.currentAccount, pinCode: state.application.pin, + isLoggedIn: state.application.isLoggedIn, }); export default connect(mapStateToProps)(withNavigation(CommunityContainer)); diff --git a/src/screens/community/screen/communityScreen.js b/src/screens/community/screen/communityScreen.js index bafcad5ca..7e78bc3da 100644 --- a/src/screens/community/screen/communityScreen.js +++ b/src/screens/community/screen/communityScreen.js @@ -31,11 +31,17 @@ const TagResultScreen = ({ navigation }) => { return ( - {({ data, handleSubscribeButtonPress, handleNewPostButtonPress, isSubscribed }) => ( + {({ + data, + handleSubscribeButtonPress, + handleNewPostButtonPress, + isSubscribed, + isLoggedIn, + }) => (
{data ? ( - + {data.description} @@ -50,22 +56,24 @@ const TagResultScreen = ({ navigation }) => { - + {isLoggedIn && ( + + )} { +const CommunitiesContainer = ({ + children, + navigation, + searchValue, + currentAccount, + pinCode, + isLoggedIn, +}) => { const [data, setData] = useState(); const [filterIndex, setFilterIndex] = useState(0); const [query, setQuery] = useState(''); @@ -31,7 +38,9 @@ const CommunitiesContainer = ({ children, navigation, searchValue, currentAccoun useEffect(() => { if (data) { getSubscriptions(currentAccount.username).then((result) => { - setAllSubscriptions(result); + if (result) { + setAllSubscriptions(result); + } }); } }, [data]); @@ -64,6 +73,7 @@ const CommunitiesContainer = ({ children, navigation, searchValue, currentAccoun handleOnVotersDropdownSelect: _handleOnVotersDropdownSelect, handleOnPress: _handleOnPress, handleSubscribeButtonPress: _handleSubscribeButtonPress, + isLoggedIn, }) ); }; @@ -71,6 +81,7 @@ const CommunitiesContainer = ({ children, navigation, searchValue, currentAccoun const mapStateToProps = (state) => ({ currentAccount: state.account.currentAccount, pinCode: state.application.pin, + isLoggedIn: state.application.isLoggedIn, }); export default connect(mapStateToProps)(withNavigation(CommunitiesContainer)); diff --git a/src/screens/searchResult/screen/CommunitiesListItem.js b/src/screens/searchResult/screen/CommunitiesListItem.js index 1736d6616..0a70871c3 100644 --- a/src/screens/searchResult/screen/CommunitiesListItem.js +++ b/src/screens/searchResult/screen/CommunitiesListItem.js @@ -21,6 +21,7 @@ const UserListItem = ({ name, handleSubscribeButtonPress, isSubscribed, + isLoggedIn, }) => { const [subscribed, setSubscribed] = useState(isSubscribed); const intl = useIntl(); @@ -40,22 +41,24 @@ const UserListItem = ({ {title} - + {isLoggedIn && ( + + )} {!!about && {about}} diff --git a/src/screens/searchResult/screen/communities.js b/src/screens/searchResult/screen/communities.js index a4824bfe0..7f3c35895 100644 --- a/src/screens/searchResult/screen/communities.js +++ b/src/screens/searchResult/screen/communities.js @@ -24,6 +24,7 @@ const CommunitiesScreen = ({ navigation, searchValue }) => { handleOnVotersDropdownSelect, handleOnPress, handleSubscribeButtonPress, + isLoggedIn, }) => ( <> { allSubscriptions={allSubscriptions} handleOnPress={handleOnPress} handleSubscribeButtonPress={handleSubscribeButtonPress} + isLoggedIn={isLoggedIn} /> )} diff --git a/src/screens/searchResult/screen/communitiesList.js b/src/screens/searchResult/screen/communitiesList.js index 87abeb563..b61eb7c14 100644 --- a/src/screens/searchResult/screen/communitiesList.js +++ b/src/screens/searchResult/screen/communitiesList.js @@ -13,6 +13,7 @@ const VotersDisplayView = ({ handleOnPress, handleSubscribeButtonPress, allSubscriptions, + isLoggedIn, }) => { const _renderItem = (item, index) => { const isSubscribed = allSubscriptions.some((sub) => sub[0] === item.name); @@ -32,6 +33,7 @@ const VotersDisplayView = ({ handleOnPress={handleOnPress} handleSubscribeButtonPress={handleSubscribeButtonPress} isSubscribed={isSubscribed} + isLoggedIn={isLoggedIn} /> ); };