community join fix, improve description height

This commit is contained in:
feruz 2022-02-23 23:06:42 +02:00
parent 3ec42e91b9
commit 6c82ec997a
3 changed files with 46 additions and 12 deletions

View File

@ -1,9 +1,12 @@
import { useState, useEffect } from 'react';
import { withNavigation } from 'react-navigation';
import get from 'lodash/get';
import { connect } from 'react-redux';
import { connect, useDispatch } from 'react-redux';
import { useIntl } from 'react-intl';
import { subscribeCommunity, getCommunity, getSubscriptions } from '../../../providers/hive/dhive';
import { getCommunity, getSubscriptions } from '../../../providers/hive/dhive';
import { subscribeCommunity, leaveCommunity } from '../../../redux/actions/communitiesAction';
import ROUTES from '../../../constants/routeNames';
@ -11,6 +14,8 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
const [data, setData] = useState(null);
const [isSubscribed, setIsSubscribed] = useState(false);
const tag = get(navigation, 'state.params.tag');
const dispatch = useDispatch();
const intl = useIntl();
useEffect(() => {
getCommunity(tag)
@ -39,17 +44,38 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
const _handleSubscribeButtonPress = () => {
const _data = {
isSubscribed: !isSubscribed,
isSubscribed: isSubscribed,
communityId: data.name,
};
const screen = 'communitiesScreenDiscoverTab';
let subscribeAction;
let successToastText = '';
let failToastText = '';
subscribeCommunity(currentAccount, pinCode, _data)
.then((result) => {
setIsSubscribed(!isSubscribed);
})
.catch((e) => {
console.log(e);
if (!_data.isSubscribed) {
subscribeAction = subscribeCommunity;
successToastText = intl.formatMessage({
id: 'alert.success_subscribe',
});
failToastText = intl.formatMessage({
id: 'alert.fail_subscribe',
});
} else {
subscribeAction = leaveCommunity;
successToastText = intl.formatMessage({
id: 'alert.success_leave',
});
failToastText = intl.formatMessage({
id: 'alert.fail_leave',
});
}
dispatch(
subscribeAction(currentAccount, pinCode, _data, successToastText, failToastText, screen),
);
setIsSubscribed(!isSubscribed);
};
const _handleNewPostButtonPress = () => {

View File

@ -1,5 +1,5 @@
import React from 'react';
import { View, Text } from 'react-native';
import { View, Text, ScrollView } from 'react-native';
import { useIntl } from 'react-intl';
// Components
@ -60,7 +60,9 @@ const CommunityScreen = ({ navigation }) => {
defaultTitle=""
>
<View style={styles.collapsibleCard}>
<Text style={styles.description}>{data.description}</Text>
<ScrollView style={styles.descriptionContainer}>
<Text style={styles.description}>{data.description}</Text>
</ScrollView>
<View style={styles.separator} />
<Text style={styles.stats}>
{`${data.subscribers} ${intl.formatMessage({

View File

@ -38,6 +38,9 @@ export default EStyleSheet.create({
marginTop: 5,
color: '$primaryBlack',
},
descriptionContainer: {
maxHeight: 250,
},
separator: {
width: 100,
alignSelf: 'center',
@ -54,7 +57,10 @@ export default EStyleSheet.create({
borderWidth: 1,
borderColor: '$primaryBlue',
},
collapsibleCard: { alignItems: 'center', marginBottom: 20 },
collapsibleCard: {
alignItems: 'center',
marginBottom: 20,
},
subscribeButtonText: {
color: '$primaryBlue',
},