Merge pull request #1849 from ecency/reply

Reply
This commit is contained in:
Feruz M 2021-02-04 12:59:47 +02:00 committed by GitHub
commit 37d975cdc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 113 additions and 29 deletions

View File

@ -58,7 +58,7 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
accountData.username = accountData.name;
dispatch(updateCurrentAccount(accountData));
dispatch(isRenderRequired(true));
//dispatch(isRenderRequired(true));
const upToDateCurrentAccount = await switchAccount(accountData.name);
const realmData = await getUserDataWithUsername(accountData.name);
@ -75,7 +75,7 @@ const AccountsBottomSheetContainer = ({ navigation }) => {
_currentAccount.local = realmData[0];
dispatch(updateCurrentAccount(_currentAccount));
dispatch(isRenderRequired(true));
//dispatch(isRenderRequired(true));
}
};

View File

@ -1,5 +1,5 @@
import AccountsBottomSheetContainer from './container/accountsBottomSheetContainer';
import AccountsBottomSheet from './view/accountsBottomSheetView';
import AccountsBottomSheet from './container/accountsBottomSheetContainer';
import AccountsBottomSheetView from './view/accountsBottomSheetView';
export { AccountsBottomSheet, AccountsBottomSheetContainer };
export default AccountsBottomSheetContainer;
export { AccountsBottomSheetView, AccountsBottomSheet };
export default AccountsBottomSheet;

View File

@ -34,27 +34,37 @@ const TagContainer = ({
const [isCommunity, setIsCommunity] = useState(false);
useEffect(() => {
let isCancelled = false;
const fetchData = async (val) => {
try {
const dd = await getCommunityTitle(val);
if (!isCancelled) {
setLabel(dd);
setIsCommunity(value !== dd);
return dd;
}
} catch (e) {
if (!isCancelled) {
setLabel(val);
setIsCommunity(/hive-[1-3]\d{4,6}$/.test(val));
return val;
}
}
};
if (value && /hive-[1-3]\d{4,6}$/.test(value)) {
if (communityTitle) {
setLabel(communityTitle);
setIsCommunity(true);
} else {
getCommunityTitle(value)
.then((r) => {
setLabel(r);
setIsCommunity(value !== r);
return r;
})
.catch((e) => {
setLabel(value);
setIsCommunity(/hive-[1-3]\d{4,6}$/.test(value));
return value;
});
fetchData(value);
}
} else {
setLabel(value);
setIsCommunity(false);
}
return () => {
isCancelled = true;
};
});
// Component Functions

View File

@ -34,6 +34,7 @@ const SelectCommunityModalView = ({
showsVerticalScrollIndicator={false}
style={styles.searchedFlatList}
data={searchedCommunities}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index, separators }) => (
<CommunityCard
community={item}
@ -66,6 +67,7 @@ const SelectCommunityModalView = ({
ItemSeparatorComponent={() => <Separator />}
showsVerticalScrollIndicator={false}
data={subscribedCommunities.data}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index, separators }) => {
const community = { name: item[0], title: item[1] };
return (
@ -89,6 +91,7 @@ const SelectCommunityModalView = ({
ItemSeparatorComponent={() => <Separator />}
showsVerticalScrollIndicator={false}
data={topCommunities.data}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index, separators }) => (
<CommunityCard
community={item}

View File

@ -1,4 +1,5 @@
import { AvatarHeader } from './avatarHeader';
import { AccountsBottomSheet } from './accountsBottomSheet';
import { BasicHeader } from './basicHeader';
import { BoostIndicatorAnimation, PulseAnimation, SpinIndicator } from './animations';
import BeneficiaryModal from './beneficiaryModal/beneficiaryModal';
@ -21,7 +22,6 @@ import { LoginHeader } from './loginHeader';
import { MainButton } from './mainButton';
import { MarkdownEditor } from './markdownEditor';
import { Modal } from './modal';
import AccountsBottomSheet from './accountsBottomSheet';
import { NotificationLine } from './notificationLine';
import { NumericKeyboard } from './numericKeyboard';
import { ParentPost } from './parentPost';
@ -112,6 +112,7 @@ import {
export {
AvatarHeader,
AccountsBottomSheet,
BasicHeader,
BeneficiaryModal,
BoostIndicatorAnimation,
@ -145,7 +146,6 @@ export {
Logo,
MainButton,
MarkdownEditor,
AccountsBottomSheet,
Modal,
NoInternetConnection,
NoPost,

View File

@ -61,4 +61,25 @@ export default EStyleSheet.create({
clearIcon: {
color: '$primaryLightGray',
},
replySection: {
paddingTop: 10,
paddingBottom: 0,
},
accountTile: {
height: 60,
flexDirection: 'row',
paddingHorizontal: 16,
alignItems: 'center',
justifyContent: 'space-between',
},
avatarAndNameContainer: {
flexDirection: 'row',
alignItems: 'center',
},
nameContainer: {
marginLeft: 2,
},
name: {
color: '$primaryDarkGray',
},
});

View File

@ -1,19 +1,37 @@
import React, { useState, useRef, useEffect, useCallback } from 'react';
import { View, KeyboardAvoidingView, FlatList, Text, Platform, ScrollView } from 'react-native';
import {
View,
KeyboardAvoidingView,
FlatList,
Text,
Platform,
ScrollView,
TouchableOpacity,
} from 'react-native';
import ActionSheet from 'react-native-actionsheet';
import { renderPostBody } from '@ecency/render-helper';
import { useDispatch, useSelector } from 'react-redux';
// Utils
import Formats from './formats/formats';
import applyImageLink from './formats/applyWebLinkFormat';
// Actions
import { toggleAccountsBottomSheet } from '../../../redux/actions/uiAction';
// Components
import { IconButton } from '../../iconButton';
import { PostBody } from '../../postElements';
import { StickyBar } from '../../basicUIElements';
import { TextInput } from '../../textInput';
// Components
import { TitleArea, TagArea, TagInput, SummaryArea } from '../../index';
import {
IconButton,
PostBody,
Separator,
StickyBar,
TextInput,
UserAvatar,
TitleArea,
TagArea,
TagInput,
SummaryArea,
} from '../../index';
import { ThemeContainer } from '../../../containers';
@ -40,6 +58,7 @@ const MarkdownEditorView = ({
onTagChanged,
onTitleChanged,
getCommunity,
currentAccount,
}) => {
const [text, setText] = useState(draftBody || '');
const [selection, setSelection] = useState({ start: 0, end: 0 });
@ -50,6 +69,11 @@ const MarkdownEditorView = ({
const galleryRef = useRef(null);
const clearRef = useRef(null);
const dispatch = useDispatch();
const isVisibleAccountsBottomSheet = useSelector(
(state) => state.ui.isVisibleAccountsBottomSheet,
);
useEffect(() => {
if (!isPreviewActive) {
_setTextAndSelection({ selection: { start: 0, end: 0 }, text });
@ -102,6 +126,13 @@ const MarkdownEditorView = ({
}
}, [text]);
const changeUser = async () => {
dispatch(toggleAccountsBottomSheet(!isVisibleAccountsBottomSheet));
if (inputRef && inputRef.current) {
inputRef.current.focus();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
const _changeText = useCallback((input) => {
setText(input);
@ -255,6 +286,18 @@ const MarkdownEditorView = ({
intl={intl}
/>
)}
{isReply && (
<View style={styles.replySection}>
<TouchableOpacity style={styles.accountTile} onPress={() => changeUser()}>
<View style={styles.avatarAndNameContainer}>
<UserAvatar noAction username={currentAccount.username} />
<View style={styles.nameContainer}>
<Text style={styles.name}>{`@${currentAccount.username}`}</Text>
</View>
</View>
</TouchableOpacity>
</View>
)}
{!isPreviewActive ? (
<ThemeContainer>
{({ isDarkTheme }) => (

View File

@ -100,6 +100,7 @@ const PostCardView = ({
return () => {
setImages({ image: DEFAULT_IMAGE, thumbnail: DEFAULT_IMAGE });
setCalcImgHeight(300);
setActiveVot([]);
};
}, [content]);

View File

@ -119,6 +119,7 @@ const PostsContainer = ({
_loadPosts,
changeForceLoadPostState,
username,
feedUsername,
forceLoadPost,
selectedOptionIndex,
selectedFeedSubfilterIndex,

View File

@ -226,6 +226,9 @@ const PostsView = ({
<View style={styles.placeholderWrapper}>
<PostCardPlaceHolder />
<PostCardPlaceHolder />
<PostCardPlaceHolder />
<PostCardPlaceHolder />
<PostCardPlaceHolder />
</View>
);
};

View File

@ -164,8 +164,8 @@ const WalletContainer = ({
isHasUnclaimedRewards = _isHasUnclaimedRewards(account[0]);
if (isHasUnclaimedRewards) {
const {
reward_steem_balance: steemBal = account[0].reward_hive_balance,
reward_sbd_balance: sbdBal = account[0].reward_hbd_balance,
reward_hive_balance: steemBal,
reward_hbd_balance: sbdBal,
reward_vesting_balance: vestingBal,
} = account[0];
return claimRewardBalance(currentAccount, pinCode, steemBal, sbdBal, vestingBal);

View File

@ -515,7 +515,7 @@ class EditorContainer extends Component {
intl.formatMessage({
id: 'alert.fail',
}),
error.error_description.split(': ')[1] || error.toString(),
error.toString(),
);
}

View File

@ -18,6 +18,7 @@ import {
SelectCommunityAreaView,
SelectCommunityModalContainer,
Modal,
UserAvatar,
} from '../../../components';
// dhive
@ -350,6 +351,7 @@ class EditorScreen extends Component {
isEdit={isEdit}
post={post}
fields={fields}
currentAccount={currentAccount}
onTagChanged={this._handleOnTagAdded}
onTitleChanged={this._handleChangeTitle}
getCommunity={this._getCommunity}