mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-02 02:07:10 +03:00
community join fix, improve description height
This commit is contained in:
parent
3ec42e91b9
commit
6c82ec997a
@ -1,9 +1,12 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { withNavigation } from 'react-navigation';
|
import { withNavigation } from 'react-navigation';
|
||||||
import get from 'lodash/get';
|
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';
|
import ROUTES from '../../../constants/routeNames';
|
||||||
|
|
||||||
@ -11,6 +14,8 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
|
|||||||
const [data, setData] = useState(null);
|
const [data, setData] = useState(null);
|
||||||
const [isSubscribed, setIsSubscribed] = useState(false);
|
const [isSubscribed, setIsSubscribed] = useState(false);
|
||||||
const tag = get(navigation, 'state.params.tag');
|
const tag = get(navigation, 'state.params.tag');
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCommunity(tag)
|
getCommunity(tag)
|
||||||
@ -39,17 +44,38 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
|
|||||||
|
|
||||||
const _handleSubscribeButtonPress = () => {
|
const _handleSubscribeButtonPress = () => {
|
||||||
const _data = {
|
const _data = {
|
||||||
isSubscribed: !isSubscribed,
|
isSubscribed: isSubscribed,
|
||||||
communityId: data.name,
|
communityId: data.name,
|
||||||
};
|
};
|
||||||
|
const screen = 'communitiesScreenDiscoverTab';
|
||||||
|
let subscribeAction;
|
||||||
|
let successToastText = '';
|
||||||
|
let failToastText = '';
|
||||||
|
|
||||||
subscribeCommunity(currentAccount, pinCode, _data)
|
if (!_data.isSubscribed) {
|
||||||
.then((result) => {
|
subscribeAction = subscribeCommunity;
|
||||||
setIsSubscribed(!isSubscribed);
|
|
||||||
})
|
successToastText = intl.formatMessage({
|
||||||
.catch((e) => {
|
id: 'alert.success_subscribe',
|
||||||
console.log(e);
|
|
||||||
});
|
});
|
||||||
|
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 = () => {
|
const _handleNewPostButtonPress = () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { View, Text } from 'react-native';
|
import { View, Text, ScrollView } from 'react-native';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
@ -60,7 +60,9 @@ const CommunityScreen = ({ navigation }) => {
|
|||||||
defaultTitle=""
|
defaultTitle=""
|
||||||
>
|
>
|
||||||
<View style={styles.collapsibleCard}>
|
<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} />
|
<View style={styles.separator} />
|
||||||
<Text style={styles.stats}>
|
<Text style={styles.stats}>
|
||||||
{`${data.subscribers} ${intl.formatMessage({
|
{`${data.subscribers} ${intl.formatMessage({
|
||||||
|
@ -38,6 +38,9 @@ export default EStyleSheet.create({
|
|||||||
marginTop: 5,
|
marginTop: 5,
|
||||||
color: '$primaryBlack',
|
color: '$primaryBlack',
|
||||||
},
|
},
|
||||||
|
descriptionContainer: {
|
||||||
|
maxHeight: 250,
|
||||||
|
},
|
||||||
separator: {
|
separator: {
|
||||||
width: 100,
|
width: 100,
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
@ -54,7 +57,10 @@ export default EStyleSheet.create({
|
|||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '$primaryBlue',
|
borderColor: '$primaryBlue',
|
||||||
},
|
},
|
||||||
collapsibleCard: { alignItems: 'center', marginBottom: 20 },
|
collapsibleCard: {
|
||||||
|
alignItems: 'center',
|
||||||
|
marginBottom: 20,
|
||||||
|
},
|
||||||
subscribeButtonText: {
|
subscribeButtonText: {
|
||||||
color: '$primaryBlue',
|
color: '$primaryBlue',
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user