mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-20 20:01:56 +03:00
commit
b3bce84840
@ -26,6 +26,7 @@ import { useAppSelector } from '../../../hooks';
|
||||
import { getUnreadNotificationCount } from '../../../providers/ecency/ecency';
|
||||
import { decryptKey } from '../../../utils/crypto';
|
||||
import { getUser as getEcencyUser} from '../../../providers/ecency/ePoint';
|
||||
import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction';
|
||||
|
||||
const AccountsBottomSheetContainer = ({ navigation }) => {
|
||||
const intl = useIntl();
|
||||
@ -109,6 +110,7 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
_currentAccount.ecencyUserData = await getEcencyUser(_currentAccount.username);
|
||||
dispatch(updateCurrentAccount(_currentAccount));
|
||||
dispatch(fetchSubscribedCommunities(_currentAccount.username))
|
||||
}
|
||||
|
||||
catch(error){
|
||||
|
@ -30,7 +30,6 @@ const PostCardContainer = ({
|
||||
setImageHeight,
|
||||
pageType,
|
||||
showQuickReplyModal,
|
||||
userCommunityRole,
|
||||
}) => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
@ -145,7 +144,6 @@ const PostCardContainer = ({
|
||||
setImageHeight={setImageHeight}
|
||||
isMuted={isMuted}
|
||||
pageType={pageType}
|
||||
userCommunityRole={userCommunityRole}
|
||||
fetchPost={_fetchPost}
|
||||
showQuickReplyModal={_handleQuickReplyModal}
|
||||
/>
|
||||
|
@ -44,7 +44,6 @@ const PostCardView = ({
|
||||
setImageHeight,
|
||||
isMuted,
|
||||
pageType,
|
||||
userCommunityRole,
|
||||
}) => {
|
||||
//local state to manage fake upvote if available
|
||||
const activeVotesCount = activeVotes ? activeVotes.length : 0;
|
||||
@ -122,12 +121,7 @@ const PostCardView = ({
|
||||
<Icon style={styles.pushPinIcon} size={20} name="pin" iconType="MaterialCommunityIcons" />
|
||||
)}
|
||||
<View style={styles.dropdownWrapper}>
|
||||
<PostDropdown
|
||||
pageType={pageType}
|
||||
userCommunityRole={userCommunityRole}
|
||||
content={content}
|
||||
fetchPost={fetchPost}
|
||||
/>
|
||||
<PostDropdown pageType={pageType} content={content} fetchPost={fetchPost} />
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.postBodyWrapper}>
|
||||
|
@ -35,7 +35,7 @@ class PostDropdownContainer extends PureComponent {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
options:OPTIONS
|
||||
options: OPTIONS
|
||||
};
|
||||
}
|
||||
|
||||
@ -67,19 +67,25 @@ 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
|
||||
const _canUpdateBlogPin = !!pageType && !!content && !!currentAccount && currentAccount.name === content.author
|
||||
const _isPinnedInProfile = !!content && content.stats?.is_pinned_blog;
|
||||
|
||||
|
||||
//check community pin update eligibility
|
||||
const _canUpdateCommunityPin = pageType === 'community' && !!content && content.community
|
||||
&& ['owner', 'admin', 'mod'].includes(userCommunityRole);
|
||||
const _canUpdateCommunityPin = subscribedCommunities.data && !!content && content.community
|
||||
? subscribedCommunities.data.reduce((role, subscription) => {
|
||||
if (content.community === subscription[0]) {
|
||||
return ['owner', 'admin', 'mod'].includes(subscription[2]);
|
||||
}
|
||||
return role;
|
||||
}, false) : false;
|
||||
const _isPinnedInCommunity = !!content && content.stats?.is_pinned;
|
||||
|
||||
//cook options list based on collected flags
|
||||
const options = OPTIONS.filter((option)=>{
|
||||
switch(option){
|
||||
const options = OPTIONS.filter((option) => {
|
||||
switch (option) {
|
||||
case 'pin-blog':
|
||||
return _canUpdateBlogPin && !_isPinnedInProfile;
|
||||
case 'unpin-blog':
|
||||
@ -159,7 +165,7 @@ class PostDropdownContainer extends PureComponent {
|
||||
this._updatePinnedPostCommunity();
|
||||
break;
|
||||
case 'unpin-community':
|
||||
this._updatePinnedPostCommunity({unpinPost:true});
|
||||
this._updatePinnedPostCommunity({ unpinPost: true });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -315,7 +321,7 @@ class PostDropdownContainer extends PureComponent {
|
||||
await pinCommunityPost(currentAccount, pinCode, content.community, content.author, content.permlink, unpinPost);
|
||||
dispatch(toastNotification(intl.formatMessage({ id: 'alert.successful' })));
|
||||
|
||||
}catch(err){
|
||||
} catch (err) {
|
||||
console.warn("Failed to update pin status of community post", err);
|
||||
Alert.alert(
|
||||
intl.formatMessage({
|
||||
@ -324,7 +330,7 @@ class PostDropdownContainer extends PureComponent {
|
||||
get(err, 'message', err.toString()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
_redirectToReply = () => {
|
||||
@ -402,6 +408,7 @@ const mapStateToProps = (state) => ({
|
||||
currentAccount: state.account.currentAccount,
|
||||
pinCode: state.application.pin,
|
||||
isPinCodeOpen: state.application.isPinCodeOpen,
|
||||
subscribedCommunities: state.communities.subscribedCommunities,
|
||||
});
|
||||
|
||||
export default withNavigation(connect(mapStateToProps)(injectIntl(PostDropdownContainer)));
|
||||
|
@ -17,7 +17,6 @@ interface postsListContainerProps extends FlatListProps<any> {
|
||||
isLoading:boolean;
|
||||
isRefreshing:boolean;
|
||||
pageType:'main'|'profile'|'ownProfile'|'community';
|
||||
userCommunityRole?:string;
|
||||
showQuickReplyModal:(post:any)=>void;
|
||||
}
|
||||
|
||||
@ -30,7 +29,6 @@ const postsListContainer = ({
|
||||
isRefreshing,
|
||||
isLoading,
|
||||
pageType,
|
||||
userCommunityRole,
|
||||
showQuickReplyModal,
|
||||
...props
|
||||
}:postsListContainerProps, ref) => {
|
||||
@ -147,7 +145,6 @@ const postsListContainer = ({
|
||||
imageHeight={imgHeight}
|
||||
setImageHeight = {_setImageHeightInMap}
|
||||
pageType={pageType}
|
||||
userCommunityRole={userCommunityRole}
|
||||
showQuickReplyModal={showQuickReplyModal}
|
||||
/>,
|
||||
);
|
||||
|
@ -17,7 +17,6 @@ export const TabbedPosts = ({
|
||||
tabContentOverrides,
|
||||
imagesToggleEnabled,
|
||||
stackedTabs,
|
||||
userCommunityRole,
|
||||
onTabChange,
|
||||
...props
|
||||
}:TabbedPostsProps) => {
|
||||
@ -74,7 +73,6 @@ export const TabbedPosts = ({
|
||||
pageType={pageType}
|
||||
filterScrollRequest={filterScrollRequest}
|
||||
onScrollRequestProcessed={_onScrollRequestProcessed}
|
||||
userCommunityRole={userCommunityRole}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
|
@ -15,7 +15,6 @@ export interface TabbedPostsProps {
|
||||
imagesToggleEnabled?:boolean,
|
||||
stackedTabs:boolean,
|
||||
pinnedPermlink?:string,
|
||||
userCommunityRole?:string,
|
||||
onTabChange:(index:number)=>void
|
||||
handleOnScroll:()=>void,
|
||||
}
|
||||
@ -60,7 +59,6 @@ export interface TabMeta {
|
||||
forceLoadPosts:boolean,
|
||||
filterScrollRequest:string,
|
||||
pinnedPermlink?:string,
|
||||
userCommunityRole?:string,
|
||||
onScrollRequestProcessed:()=>void
|
||||
handleOnScroll:()=>void;
|
||||
}
|
@ -33,7 +33,6 @@ const TabContent = ({
|
||||
feedUsername,
|
||||
tag,
|
||||
pinnedPermlink,
|
||||
userCommunityRole,
|
||||
onScrollRequestProcessed,
|
||||
handleOnScroll,
|
||||
...props
|
||||
@ -47,9 +46,12 @@ const TabContent = ({
|
||||
const isAnalytics = useSelector((state) => state.application.isAnalytics);
|
||||
const nsfw = useSelector((state) => state.application.nsfw);
|
||||
const isConnected = useSelector((state) => state.application.isConnected);
|
||||
const {name:username, about:{profile:{pinned}}} = useSelector((state) => state.account.currentAccount);
|
||||
const currentAccount = useSelector((state) => state.account.currentAccount);
|
||||
const initPosts = useSelector((state) => state.posts.initPosts)
|
||||
|
||||
const username = currentAccount.username;
|
||||
const curPinned = currentAccount.about?.pinned;
|
||||
|
||||
|
||||
//state
|
||||
const [posts, setPosts] = useState([]);
|
||||
@ -72,6 +74,8 @@ const TabContent = ({
|
||||
sessionUserRef.current = sessionUser;
|
||||
|
||||
|
||||
|
||||
|
||||
//side effects
|
||||
useEffect(() => {
|
||||
|
||||
@ -101,13 +105,11 @@ const TabContent = ({
|
||||
}, [filterScrollRequest])
|
||||
|
||||
useEffect(()=>{
|
||||
if(pageType === 'ownProfile' && pinned !== pinnedPermlink ){
|
||||
// setPinnedPermlink(pinnedPermlink)
|
||||
// alert("This is called")
|
||||
if(pageType === 'ownProfile' && curPinned !== pinnedPermlink ){
|
||||
_scrollToTop();
|
||||
_loadPosts({shouldReset:true, _pinnedPermlink:pinned})
|
||||
_loadPosts({shouldReset:true, _pinnedPermlink:curPinned})
|
||||
}
|
||||
},[pinned])
|
||||
},[curPinned])
|
||||
|
||||
|
||||
const _cleanup = () => {
|
||||
@ -359,7 +361,6 @@ const TabContent = ({
|
||||
isLoading={tabMeta.isLoading}
|
||||
ListEmptyComponent={_renderEmptyContent}
|
||||
pageType={pageType}
|
||||
userCommunityRole={userCommunityRole}
|
||||
showQuickReplyModal={_showQuickReplyModal}
|
||||
/>
|
||||
<ScrollTopPopup
|
||||
|
@ -3,7 +3,6 @@ import sha256 from 'crypto-js/sha256';
|
||||
import Config from 'react-native-config';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import { Alert } from 'react-native';
|
||||
import { getDigitPinCode, getMutes, getUser } from './dhive';
|
||||
import { getUser as getEcencyUser } from '../ecency/ePoint';
|
||||
import {
|
||||
|
@ -107,6 +107,7 @@ import parseVersionNumber from '../../../utils/parseVersionNumber';
|
||||
import { getTimeFromNow, setMomentLocale } from '../../../utils/time';
|
||||
import parseAuthUrl from '../../../utils/parseAuthUrl';
|
||||
import { purgeExpiredCache } from '../../../redux/actions/cacheActions';
|
||||
import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction';
|
||||
|
||||
// Workaround
|
||||
let previousAppState = 'background';
|
||||
@ -764,7 +765,7 @@ class ApplicationContainer extends Component {
|
||||
accountData.mutes = await getMutes(realmObject.username);
|
||||
accountData.ecencyUserData = await getEcencyUser(realmObject.username);
|
||||
dispatch(updateCurrentAccount(accountData));
|
||||
|
||||
dispatch(fetchSubscribedCommunities(realmObject.username));
|
||||
this._connectNotificationServer(accountData.name);
|
||||
} catch (err) {
|
||||
Alert.alert(
|
||||
@ -945,6 +946,7 @@ class ApplicationContainer extends Component {
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
_currentAccount.ecencyUserData = await getEcencyUser(_currentAccount.username);
|
||||
dispatch(updateCurrentAccount(_currentAccount));
|
||||
dispatch(fetchSubscribedCommunities(_currentAccount.username));
|
||||
};
|
||||
|
||||
_handleWelcomeModalButtonPress = () => {
|
||||
|
@ -13,7 +13,6 @@ import ROUTES from '../../../constants/routeNames';
|
||||
const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isLoggedIn }) => {
|
||||
const [data, setData] = useState(null);
|
||||
const [isSubscribed, setIsSubscribed] = useState(false);
|
||||
const [userRole, setUserRole] = useState('guest');
|
||||
const tag = get(navigation, 'state.params.tag');
|
||||
const dispatch = useDispatch();
|
||||
const intl = useIntl();
|
||||
@ -31,25 +30,11 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
//check and set user role
|
||||
let _hasTeamRole = false;
|
||||
if (data.team && currentAccount) {
|
||||
const member = data.team.find((m) => m[0] === currentAccount.username);
|
||||
const role = member ? member[1] : userRole;
|
||||
_hasTeamRole = !!member;
|
||||
setUserRole(role);
|
||||
}
|
||||
|
||||
getSubscriptions(currentAccount.username)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
const _isSubscribed = result.some((item) => item[0] === data.name);
|
||||
setIsSubscribed(_isSubscribed);
|
||||
|
||||
if (_isSubscribed && !_hasTeamRole) {
|
||||
//if userRole default value is not overwritten,
|
||||
//means user is not a part of community core team, so setting as member
|
||||
setUserRole('member');
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
@ -112,7 +97,6 @@ const CommunityContainer = ({ children, navigation, currentAccount, pinCode, isL
|
||||
handleNewPostButtonPress: _handleNewPostButtonPress,
|
||||
isSubscribed,
|
||||
isLoggedIn,
|
||||
userRole,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
@ -43,7 +43,6 @@ const CommunityScreen = ({ navigation }) => {
|
||||
handleNewPostButtonPress,
|
||||
isSubscribed,
|
||||
isLoggedIn,
|
||||
userRole,
|
||||
}) => (
|
||||
<View style={styles.container}>
|
||||
<BasicHeader
|
||||
@ -117,7 +116,6 @@ const CommunityScreen = ({ navigation }) => {
|
||||
selectedOptionIndex={_getSelectedIndex()}
|
||||
tag={tag}
|
||||
pageType="community"
|
||||
userCommunityRole={userRole}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
@ -34,6 +34,7 @@ import ROUTES from '../../../constants/routeNames';
|
||||
// Component
|
||||
import LoginScreen from '../screen/loginScreen';
|
||||
import persistAccountGenerator from '../../../utils/persistAccountGenerator';
|
||||
import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction';
|
||||
|
||||
/*
|
||||
* Props Name Description Value
|
||||
@ -65,6 +66,7 @@ class LoginContainer extends PureComponent {
|
||||
const persistAccountData = persistAccountGenerator(result);
|
||||
|
||||
dispatch(updateCurrentAccount({ ...result }));
|
||||
dispatch(fetchSubscribedCommunities(username));
|
||||
dispatch(addOtherAccount({ ...persistAccountData }));
|
||||
dispatch(loginAction(true));
|
||||
dispatch(setInitPosts([]));
|
||||
|
@ -44,6 +44,7 @@ import { encryptKey, decryptKey } from '../../../utils/crypto';
|
||||
// Component
|
||||
import PinCodeScreen from '../screen/pinCodeScreen';
|
||||
import { getUnreadNotificationCount } from '../../../providers/ecency/ecency';
|
||||
import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction';
|
||||
|
||||
class PinCodeContainer extends Component {
|
||||
constructor(props) {
|
||||
@ -322,6 +323,7 @@ class PinCodeContainer extends Component {
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
_currentAccount.ecencyUserData = await getEcencyUser(_currentAccount.username);
|
||||
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
||||
dispatch(fetchSubscribedCommunities(_currentAccount.username));
|
||||
dispatch(closePinCodeModal());
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import { login as loginAction, openPinCodeModal } from '../../redux/actions/appl
|
||||
// Constants
|
||||
import { default as ROUTES } from '../../constants/routeNames';
|
||||
import persistAccountGenerator from '../../utils/persistAccountGenerator';
|
||||
import { fetchSubscribedCommunities } from '../../redux/actions/communitiesAction';
|
||||
|
||||
class HiveSigner extends PureComponent {
|
||||
constructor(props) {
|
||||
@ -45,6 +46,7 @@ class HiveSigner extends PureComponent {
|
||||
const persistAccountData = persistAccountGenerator(result);
|
||||
|
||||
dispatch(updateCurrentAccount({ ...result }));
|
||||
dispatch(fetchSubscribedCommunities(result.username));
|
||||
dispatch(addOtherAccount({ ...persistAccountData }));
|
||||
dispatch(loginAction(true));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user