mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-02 11:15:35 +03:00
Merge pull request #1727 from ecency/bugfix/community
Fixed community bugs
This commit is contained in:
commit
ea8dbf1a1a
@ -25,6 +25,7 @@ class TagContainer extends PureComponent {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
label: props.value,
|
label: props.value,
|
||||||
|
isCommunity: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Component Life Cycle Functions
|
// Component Life Cycle Functions
|
||||||
@ -35,6 +36,7 @@ class TagContainer extends PureComponent {
|
|||||||
.then((r) => {
|
.then((r) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
label: r,
|
label: r,
|
||||||
|
isCommunity: value !== r,
|
||||||
});
|
});
|
||||||
return r;
|
return r;
|
||||||
})
|
})
|
||||||
@ -43,12 +45,13 @@ class TagContainer extends PureComponent {
|
|||||||
// Component Functions
|
// Component Functions
|
||||||
_handleOnTagPress = () => {
|
_handleOnTagPress = () => {
|
||||||
const { navigation, onPress, value } = this.props;
|
const { navigation, onPress, value } = this.props;
|
||||||
|
const { isCommunity } = this.state;
|
||||||
|
|
||||||
if (onPress) {
|
if (onPress) {
|
||||||
onPress();
|
onPress();
|
||||||
} else {
|
} else {
|
||||||
navigation.navigate({
|
navigation.navigate({
|
||||||
routeName: ROUTES.SCREENS.TAG_RESULT,
|
routeName: isCommunity ? ROUTES.SCREENS.COMMUNITY : ROUTES.SCREENS.TAG_RESULT,
|
||||||
params: {
|
params: {
|
||||||
tag: value,
|
tag: value,
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,7 @@ import { subscribeCommunity } from '../../../providers/steem/dsteem';
|
|||||||
|
|
||||||
import ROUTES from '../../../constants/routeNames';
|
import ROUTES from '../../../constants/routeNames';
|
||||||
|
|
||||||
const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) => {
|
const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isLoggedIn }) => {
|
||||||
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');
|
||||||
@ -22,8 +22,10 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) =
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
getSubscriptions(currentAccount.username).then((result) => {
|
getSubscriptions(currentAccount.username).then((result) => {
|
||||||
|
if (result) {
|
||||||
const _isSubscribed = result.some((item) => item[0] === data.name);
|
const _isSubscribed = result.some((item) => item[0] === data.name);
|
||||||
setIsSubscribed(_isSubscribed);
|
setIsSubscribed(_isSubscribed);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
@ -54,7 +56,8 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) =
|
|||||||
data,
|
data,
|
||||||
handleSubscribeButtonPress: _handleSubscribeButtonPress,
|
handleSubscribeButtonPress: _handleSubscribeButtonPress,
|
||||||
handleNewPostButtonPress: _handleNewPostButtonPress,
|
handleNewPostButtonPress: _handleNewPostButtonPress,
|
||||||
isSubscribed: isSubscribed,
|
isSubscribed,
|
||||||
|
isLoggedIn,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -62,6 +65,7 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode }) =
|
|||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
currentAccount: state.account.currentAccount,
|
currentAccount: state.account.currentAccount,
|
||||||
pinCode: state.application.pin,
|
pinCode: state.application.pin,
|
||||||
|
isLoggedIn: state.application.isLoggedIn,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withNavigation(CommunityContainer));
|
export default connect(mapStateToProps)(withNavigation(CommunityContainer));
|
||||||
|
@ -31,11 +31,17 @@ const TagResultScreen = ({ navigation }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<CommunityContainer>
|
<CommunityContainer>
|
||||||
{({ data, handleSubscribeButtonPress, handleNewPostButtonPress, isSubscribed }) => (
|
{({
|
||||||
|
data,
|
||||||
|
handleSubscribeButtonPress,
|
||||||
|
handleNewPostButtonPress,
|
||||||
|
isSubscribed,
|
||||||
|
isLoggedIn,
|
||||||
|
}) => (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Header isReverse hideUser />
|
<Header isReverse hideUser />
|
||||||
{data ? (
|
{data ? (
|
||||||
<CollapsibleCard title={data.title} isTitleCenter defaultTitle="">
|
<CollapsibleCard title={data.title} isTitleCenter defaultTitle="" expanded>
|
||||||
<View style={styles.collapsibleCard}>
|
<View style={styles.collapsibleCard}>
|
||||||
<Text style={styles.description}>{data.description}</Text>
|
<Text style={styles.description}>{data.description}</Text>
|
||||||
<View style={styles.separator} />
|
<View style={styles.separator} />
|
||||||
@ -50,11 +56,12 @@ const TagResultScreen = ({ navigation }) => {
|
|||||||
</Text>
|
</Text>
|
||||||
<View style={styles.separator} />
|
<View style={styles.separator} />
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
|
{isLoggedIn && (
|
||||||
<Tag
|
<Tag
|
||||||
style={styles.subscribeButton}
|
style={styles.subscribeButton}
|
||||||
textStyle={!isSubscribed && styles.subscribeButtonText}
|
textStyle={isSubscribed && styles.subscribeButtonText}
|
||||||
value={
|
value={
|
||||||
isSubscribed
|
!isSubscribed
|
||||||
? intl.formatMessage({
|
? intl.formatMessage({
|
||||||
id: 'search_result.communities.subscribe',
|
id: 'search_result.communities.subscribe',
|
||||||
})
|
})
|
||||||
@ -62,10 +69,11 @@ const TagResultScreen = ({ navigation }) => {
|
|||||||
id: 'search_result.communities.unsubscribe',
|
id: 'search_result.communities.unsubscribe',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
isPin={isSubscribed}
|
isPin={!isSubscribed}
|
||||||
isFilter
|
isFilter
|
||||||
onPress={handleSubscribeButtonPress}
|
onPress={handleSubscribeButtonPress}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<Tag
|
<Tag
|
||||||
style={styles.subscribeButton}
|
style={styles.subscribeButton}
|
||||||
value={intl.formatMessage({
|
value={intl.formatMessage({
|
||||||
|
@ -731,7 +731,7 @@ class EditorContainer extends Component {
|
|||||||
uploadedImage,
|
uploadedImage,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
const tags = navigation.state.params.tags;
|
const tags = navigation.state.params && navigation.state.params.tags;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EditorScreen
|
<EditorScreen
|
||||||
|
@ -7,7 +7,14 @@ import ROUTES from '../../../constants/routeNames';
|
|||||||
import { getCommunities, getSubscriptions } from '../../../providers/steem/steem';
|
import { getCommunities, getSubscriptions } from '../../../providers/steem/steem';
|
||||||
import { subscribeCommunity } from '../../../providers/steem/dsteem';
|
import { subscribeCommunity } from '../../../providers/steem/dsteem';
|
||||||
|
|
||||||
const CommunitiesContainer = ({ children, navigation, searchValue, currentAccount, pinCode }) => {
|
const CommunitiesContainer = ({
|
||||||
|
children,
|
||||||
|
navigation,
|
||||||
|
searchValue,
|
||||||
|
currentAccount,
|
||||||
|
pinCode,
|
||||||
|
isLoggedIn,
|
||||||
|
}) => {
|
||||||
const [data, setData] = useState();
|
const [data, setData] = useState();
|
||||||
const [filterIndex, setFilterIndex] = useState(0);
|
const [filterIndex, setFilterIndex] = useState(0);
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
@ -31,7 +38,9 @@ const CommunitiesContainer = ({ children, navigation, searchValue, currentAccoun
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
getSubscriptions(currentAccount.username).then((result) => {
|
getSubscriptions(currentAccount.username).then((result) => {
|
||||||
|
if (result) {
|
||||||
setAllSubscriptions(result);
|
setAllSubscriptions(result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
@ -64,6 +73,7 @@ const CommunitiesContainer = ({ children, navigation, searchValue, currentAccoun
|
|||||||
handleOnVotersDropdownSelect: _handleOnVotersDropdownSelect,
|
handleOnVotersDropdownSelect: _handleOnVotersDropdownSelect,
|
||||||
handleOnPress: _handleOnPress,
|
handleOnPress: _handleOnPress,
|
||||||
handleSubscribeButtonPress: _handleSubscribeButtonPress,
|
handleSubscribeButtonPress: _handleSubscribeButtonPress,
|
||||||
|
isLoggedIn,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -71,6 +81,7 @@ const CommunitiesContainer = ({ children, navigation, searchValue, currentAccoun
|
|||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
currentAccount: state.account.currentAccount,
|
currentAccount: state.account.currentAccount,
|
||||||
pinCode: state.application.pin,
|
pinCode: state.application.pin,
|
||||||
|
isLoggedIn: state.application.isLoggedIn,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withNavigation(CommunitiesContainer));
|
export default connect(mapStateToProps)(withNavigation(CommunitiesContainer));
|
||||||
|
@ -21,6 +21,7 @@ const UserListItem = ({
|
|||||||
name,
|
name,
|
||||||
handleSubscribeButtonPress,
|
handleSubscribeButtonPress,
|
||||||
isSubscribed,
|
isSubscribed,
|
||||||
|
isLoggedIn,
|
||||||
}) => {
|
}) => {
|
||||||
const [subscribed, setSubscribed] = useState(isSubscribed);
|
const [subscribed, setSubscribed] = useState(isSubscribed);
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@ -40,11 +41,12 @@ const UserListItem = ({
|
|||||||
<View style={styles.content}>
|
<View style={styles.content}>
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<Text style={styles.title}>{title}</Text>
|
<Text style={styles.title}>{title}</Text>
|
||||||
|
{isLoggedIn && (
|
||||||
<Tag
|
<Tag
|
||||||
style={styles.subscribeButton}
|
style={styles.subscribeButton}
|
||||||
textStyle={!subscribed && styles.subscribeButtonText}
|
textStyle={subscribed && styles.subscribeButtonText}
|
||||||
value={
|
value={
|
||||||
subscribed
|
!subscribed
|
||||||
? intl.formatMessage({
|
? intl.formatMessage({
|
||||||
id: 'search_result.communities.subscribe',
|
id: 'search_result.communities.subscribe',
|
||||||
})
|
})
|
||||||
@ -52,10 +54,11 @@ const UserListItem = ({
|
|||||||
id: 'search_result.communities.unsubscribe',
|
id: 'search_result.communities.unsubscribe',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
isPin={subscribed}
|
isPin={!subscribed}
|
||||||
isFilter
|
isFilter
|
||||||
onPress={_handleSubscribeButtonPress}
|
onPress={_handleSubscribeButtonPress}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
{!!about && <Text style={styles.about}>{about}</Text>}
|
{!!about && <Text style={styles.about}>{about}</Text>}
|
||||||
<View style={styles.separator} />
|
<View style={styles.separator} />
|
||||||
|
@ -24,6 +24,7 @@ const CommunitiesScreen = ({ navigation, searchValue }) => {
|
|||||||
handleOnVotersDropdownSelect,
|
handleOnVotersDropdownSelect,
|
||||||
handleOnPress,
|
handleOnPress,
|
||||||
handleSubscribeButtonPress,
|
handleSubscribeButtonPress,
|
||||||
|
isLoggedIn,
|
||||||
}) => (
|
}) => (
|
||||||
<>
|
<>
|
||||||
<FilterBar
|
<FilterBar
|
||||||
@ -44,6 +45,7 @@ const CommunitiesScreen = ({ navigation, searchValue }) => {
|
|||||||
allSubscriptions={allSubscriptions}
|
allSubscriptions={allSubscriptions}
|
||||||
handleOnPress={handleOnPress}
|
handleOnPress={handleOnPress}
|
||||||
handleSubscribeButtonPress={handleSubscribeButtonPress}
|
handleSubscribeButtonPress={handleSubscribeButtonPress}
|
||||||
|
isLoggedIn={isLoggedIn}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -13,6 +13,7 @@ const VotersDisplayView = ({
|
|||||||
handleOnPress,
|
handleOnPress,
|
||||||
handleSubscribeButtonPress,
|
handleSubscribeButtonPress,
|
||||||
allSubscriptions,
|
allSubscriptions,
|
||||||
|
isLoggedIn,
|
||||||
}) => {
|
}) => {
|
||||||
const _renderItem = (item, index) => {
|
const _renderItem = (item, index) => {
|
||||||
const isSubscribed = allSubscriptions.some((sub) => sub[0] === item.name);
|
const isSubscribed = allSubscriptions.some((sub) => sub[0] === item.name);
|
||||||
@ -32,6 +33,7 @@ const VotersDisplayView = ({
|
|||||||
handleOnPress={handleOnPress}
|
handleOnPress={handleOnPress}
|
||||||
handleSubscribeButtonPress={handleSubscribeButtonPress}
|
handleSubscribeButtonPress={handleSubscribeButtonPress}
|
||||||
isSubscribed={isSubscribed}
|
isSubscribed={isSubscribed}
|
||||||
|
isLoggedIn={isLoggedIn}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user