mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-04 12:05:54 +03:00
utilising subscribedCommunities cache to set user community role
This commit is contained in:
parent
9d5c752802
commit
b14cc05784
@ -67,14 +67,23 @@ class PostDropdownContainer extends PureComponent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_initOptions = ({content, currentAccount, pageType, userCommunityRole} = this.props) => {
|
_initOptions = ({content, currentAccount, pageType, subscribedCommunities} = this.props) => {
|
||||||
//check if post is owned by current user or not, if so pinned or not
|
//check if post is owned by current user or not, if so pinned or not
|
||||||
const _canUpdateBlogPin = !!pageType && !!content && !!currentAccount && currentAccount.name === content.author
|
const _canUpdateBlogPin = !!pageType && !!content && !!currentAccount && currentAccount.name === content.author
|
||||||
const _isPinnedInProfile = !!content && content.stats?.is_pinned_blog;
|
const _isPinnedInProfile = !!content && content.stats?.is_pinned_blog;
|
||||||
|
|
||||||
|
//get user role for community;
|
||||||
|
const defaultRole = 'guest';
|
||||||
|
const _userCommunitiyRole = subscribedCommunities.data && !!content && content.community ? subscribedCommunities.data.reduce((role, subscription)=>{
|
||||||
|
if(content.community === subscription[0]){
|
||||||
|
return subscription[2];
|
||||||
|
}
|
||||||
|
return role;
|
||||||
|
}, defaultRole) : defaultRole;
|
||||||
|
|
||||||
//check community pin update eligibility
|
//check community pin update eligibility
|
||||||
const _canUpdateCommunityPin = pageType === 'community' && !!content && content.community
|
const _canUpdateCommunityPin = !!content && content.community
|
||||||
&& ['owner', 'admin', 'mod'].includes(userCommunityRole);
|
&& ['owner', 'admin', 'mod'].includes(_userCommunitiyRole);
|
||||||
const _isPinnedInCommunity = !!content && content.stats?.is_pinned;
|
const _isPinnedInCommunity = !!content && content.stats?.is_pinned;
|
||||||
|
|
||||||
//cook options list based on collected flags
|
//cook options list based on collected flags
|
||||||
@ -402,6 +411,7 @@ const mapStateToProps = (state) => ({
|
|||||||
currentAccount: state.account.currentAccount,
|
currentAccount: state.account.currentAccount,
|
||||||
pinCode: state.application.pin,
|
pinCode: state.application.pin,
|
||||||
isPinCodeOpen: state.application.isPinCodeOpen,
|
isPinCodeOpen: state.application.isPinCodeOpen,
|
||||||
|
subscribedCommunities: state.communities.subscribedCommunities,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withNavigation(connect(mapStateToProps)(injectIntl(PostDropdownContainer)));
|
export default withNavigation(connect(mapStateToProps)(injectIntl(PostDropdownContainer)));
|
||||||
|
Loading…
Reference in New Issue
Block a user