mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 19:31:54 +03:00
Merge remote-tracking branch 'origin/development' into nt/navigation
This commit is contained in:
commit
7fd2d3471e
@ -44,6 +44,7 @@ const BeneficiarySelectionContent = ({
|
||||
|
||||
const beneficiariesMap = useAppSelector((state) => state.editor.beneficiariesMap);
|
||||
const username = useAppSelector((state) => state.account.currentAccount.name);
|
||||
const DEFAULT_BENEFICIARY = { account: username, weight: 10000 };
|
||||
|
||||
const [beneficiaries, setBeneficiaries] = useState<Beneficiary[]>([
|
||||
{ account: username, weight: 10000, autoPowerUp: false },
|
||||
@ -94,8 +95,9 @@ const BeneficiarySelectionContent = ({
|
||||
|
||||
const readTempBeneficiaries = async () => {
|
||||
if (beneficiariesMap) {
|
||||
const tempBeneficiaries = beneficiariesMap[draftId || TEMP_BENEFICIARIES_ID];
|
||||
|
||||
const savedBeneficiareis = beneficiariesMap[draftId || TEMP_BENEFICIARIES_ID];
|
||||
const tempBeneficiaries = savedBeneficiareis && savedBeneficiareis.length ? [DEFAULT_BENEFICIARY, ...beneficiariesMap[draftId || TEMP_BENEFICIARIES_ID]] : [DEFAULT_BENEFICIARY];
|
||||
|
||||
if (isArray(tempBeneficiaries) && tempBeneficiaries.length > 0) {
|
||||
//weight correction algorithm.
|
||||
let othersWeight = 0;
|
||||
@ -105,17 +107,17 @@ const BeneficiarySelectionContent = ({
|
||||
}
|
||||
});
|
||||
tempBeneficiaries[0].weight = 10000 - othersWeight;
|
||||
|
||||
setBeneficiaries(tempBeneficiaries);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const _saveBeneficiaries = (value: Beneficiary[]) => {
|
||||
const filteredBeneficiaries = value.filter((item) => item.account !== username); //remove default beneficiary from array while saving
|
||||
if (handleSaveBeneficiary) {
|
||||
handleSaveBeneficiary(value);
|
||||
handleSaveBeneficiary(filteredBeneficiaries);
|
||||
} else {
|
||||
dispatch(setBeneficiariesAction(draftId || TEMP_BENEFICIARIES_ID, value));
|
||||
dispatch(setBeneficiariesAction(draftId || TEMP_BENEFICIARIES_ID, filteredBeneficiaries));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,6 @@ interface PostOptionsModalProps {
|
||||
isEdit:boolean;
|
||||
isCommunityPost:boolean;
|
||||
rewardType: string;
|
||||
scheduledForDate: string | null;
|
||||
handleRewardChange:(rewardType:string)=>void;
|
||||
handleThumbSelection:(index:number)=>void;
|
||||
handleScheduleChange:(datetime:string|null)=>void;
|
||||
@ -52,7 +51,6 @@ const PostOptionsModal = forwardRef(({
|
||||
isEdit,
|
||||
isCommunityPost,
|
||||
rewardType,
|
||||
scheduledForDate,
|
||||
handleRewardChange,
|
||||
handleThumbSelection,
|
||||
handleScheduleChange,
|
||||
@ -63,13 +61,13 @@ const PostOptionsModal = forwardRef(({
|
||||
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [rewardTypeIndex, setRewardTypeIndex] = useState(0);
|
||||
const [scheduleLater, setScheduleLater] = useState(scheduledForDate ? true : false);
|
||||
const [scheduleLater, setScheduleLater] = useState(false);
|
||||
const [shouldReblog, setShouldReblog] = useState(false);
|
||||
const [scheduledFor, setScheduledFor] = useState('');
|
||||
const [disableDone, setDisableDone] = useState(false);
|
||||
|
||||
// removed the useeffect causing index reset bug
|
||||
/*
|
||||
|
||||
useEffect(()=>{
|
||||
if(!scheduleLater){
|
||||
handleScheduleChange(null)
|
||||
@ -77,22 +75,6 @@ const PostOptionsModal = forwardRef(({
|
||||
handleScheduleChange(scheduledFor)
|
||||
}
|
||||
}, [scheduleLater, scheduledFor])
|
||||
*/
|
||||
useEffect(() => {
|
||||
if(scheduledFor){
|
||||
handleScheduleChange(scheduledFor);
|
||||
}
|
||||
},[scheduledFor])
|
||||
|
||||
useEffect(() => {
|
||||
if (scheduledForDate) {
|
||||
setScheduleLater(true);
|
||||
setScheduledFor(scheduledForDate);
|
||||
} else {
|
||||
setScheduleLater(false);
|
||||
setScheduledFor('');
|
||||
}
|
||||
},[scheduledForDate])
|
||||
|
||||
useEffect(() => {
|
||||
handleShouldReblogChange(shouldReblog)
|
||||
@ -168,7 +150,6 @@ const PostOptionsModal = forwardRef(({
|
||||
<AnimatedView animation="flipInX" duration={700}>
|
||||
<DateTimePicker
|
||||
type="datetime"
|
||||
selectedDate={scheduledForDate}
|
||||
onChanged={_handleDatePickerChange}
|
||||
disabled={true}
|
||||
/>
|
||||
|
@ -5,6 +5,7 @@ import { Alert } from 'react-native';
|
||||
import ImagePicker from 'react-native-image-crop-picker';
|
||||
import get from 'lodash/get';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import { isArray } from 'lodash';
|
||||
|
||||
// Services and Actions
|
||||
import { Buffer } from 'buffer';
|
||||
@ -76,7 +77,6 @@ class EditorContainer extends Component<any, any> {
|
||||
isDraft: false,
|
||||
community: [],
|
||||
rewardType: 'default',
|
||||
scheduledForDate: null,
|
||||
sharedSnippetText: null,
|
||||
onLoadDraftPress: false,
|
||||
thumbIndex: 0,
|
||||
@ -254,7 +254,7 @@ class EditorContainer extends Component<any, any> {
|
||||
|
||||
// load meta from local/param drfat into state
|
||||
_loadMeta = (draft: any) => {
|
||||
const { dispatch } = this.props;
|
||||
const { dispatch, currentAccount } = this.props;
|
||||
// if meta exist on draft, get the index of 1st image in meta from images urls in body
|
||||
const body = draft.body;
|
||||
if (draft.meta && draft.meta.image) {
|
||||
@ -264,12 +264,6 @@ class EditorContainer extends Component<any, any> {
|
||||
thumbIndex: draftThumbIndex,
|
||||
});
|
||||
}
|
||||
// load schedule date
|
||||
if (draft.meta && draft.meta.scheduledFor) {
|
||||
this.setState({
|
||||
scheduledForDate: draft.meta.scheduledFor,
|
||||
});
|
||||
}
|
||||
|
||||
// load beneficiaries and rewards data from meta field of draft
|
||||
if (draft.meta && draft.meta.rewardType) {
|
||||
@ -279,7 +273,10 @@ class EditorContainer extends Component<any, any> {
|
||||
}
|
||||
|
||||
if (draft._id && draft.meta && draft.meta.beneficiaries) {
|
||||
dispatch(setBeneficiaries(draft._id || TEMP_BENEFICIARIES_ID, draft.meta.beneficiaries));
|
||||
if(isArray(draft.meta.beneficiaries)){
|
||||
const filteredBeneficiaries = draft.meta.beneficiaries.filter((item) => item.account !== currentAccount.username); //remove default beneficiary from array while saving
|
||||
dispatch(setBeneficiaries(draft._id || TEMP_BENEFICIARIES_ID, filteredBeneficiaries));
|
||||
}
|
||||
}
|
||||
}
|
||||
_requestKeyboardFocus = () => {
|
||||
@ -625,8 +622,8 @@ class EditorContainer extends Component<any, any> {
|
||||
draftId: response._id,
|
||||
});
|
||||
}
|
||||
|
||||
dispatch(setBeneficiaries(response._id, beneficiaries));
|
||||
const filteredBeneficiaries = beneficiaries.filter((item) => item.account !== currentAccount.username); //remove default beneficiary from array while saving
|
||||
dispatch(setBeneficiaries(response._id, filteredBeneficiaries));
|
||||
dispatch(removeBeneficiaries(TEMP_BENEFICIARIES_ID));
|
||||
|
||||
//clear local copy if darft save is successful
|
||||
@ -1231,9 +1228,6 @@ class EditorContainer extends Component<any, any> {
|
||||
this.setState({ rewardType: value });
|
||||
};
|
||||
|
||||
_handleScheduleDateChange = (value) => {
|
||||
this.setState({ scheduledForDate: value })
|
||||
};
|
||||
|
||||
_handleShouldReblogChange = (value: boolean) => {
|
||||
this.setState({
|
||||
@ -1270,7 +1264,6 @@ class EditorContainer extends Component<any, any> {
|
||||
thumbIndex,
|
||||
uploadProgress,
|
||||
rewardType,
|
||||
scheduledForDate,
|
||||
} = this.state;
|
||||
|
||||
const tags = route.params?.tags;
|
||||
@ -1279,7 +1272,6 @@ class EditorContainer extends Component<any, any> {
|
||||
autoFocusText={autoFocusText}
|
||||
draftPost={draftPost}
|
||||
handleRewardChange={this._handleRewardChange}
|
||||
handleScheduleDateChange={this._handleScheduleDateChange}
|
||||
handleShouldReblogChange={this._handleShouldReblogChange}
|
||||
handleSchedulePress={this._handleSchedulePress}
|
||||
handleFormChanged={this._handleFormChanged}
|
||||
@ -1312,7 +1304,6 @@ class EditorContainer extends Component<any, any> {
|
||||
setThumbIndex={this._handleSetThumbIndex}
|
||||
uploadProgress={uploadProgress}
|
||||
rewardType={rewardType}
|
||||
scheduledForDate={scheduledForDate}
|
||||
getBeneficiaries={this._extractBeneficiaries}
|
||||
|
||||
/>
|
||||
|
@ -51,13 +51,13 @@ class EditorScreen extends Component {
|
||||
isCommunitiesListModalOpen: false,
|
||||
selectedCommunity: null,
|
||||
selectedAccount: null,
|
||||
scheduledFor: (props.scheduledForDate && props.scheduledForDate) || null,
|
||||
scheduledFor: null,
|
||||
};
|
||||
}
|
||||
|
||||
// Component Life Cycles
|
||||
componentDidMount() {
|
||||
const { draftPost, currentAccount, scheduledForDate } = this.props;
|
||||
const { draftPost, currentAccount } = this.props;
|
||||
|
||||
if (draftPost) {
|
||||
if (draftPost.tags?.length > 0 && isCommunity(draftPost.tags[0])) {
|
||||
@ -68,9 +68,6 @@ class EditorScreen extends Component {
|
||||
});
|
||||
}
|
||||
}
|
||||
if(scheduledForDate){
|
||||
this._handleScheduleChange(scheduledForDate);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@ -204,11 +201,9 @@ class EditorScreen extends Component {
|
||||
|
||||
|
||||
_handleScheduleChange = (datetime:string|null) => {
|
||||
const { handleScheduleDateChange } = this.props;
|
||||
this.setState({
|
||||
scheduledFor:datetime,
|
||||
})
|
||||
handleScheduleDateChange(datetime);
|
||||
}
|
||||
|
||||
_handleRewardChange = (value) => {
|
||||
@ -241,8 +236,8 @@ class EditorScreen extends Component {
|
||||
};
|
||||
|
||||
_handleFormUpdate = (componentID, content) => {
|
||||
const { handleFormChanged, thumbIndex, rewardType, getBeneficiaries, scheduledForDate } = this.props;
|
||||
const { fields: _fields, scheduledFor } = this.state;
|
||||
const { handleFormChanged, thumbIndex, rewardType, getBeneficiaries } = this.props;
|
||||
const { fields: _fields } = this.state;
|
||||
const fields = { ..._fields };
|
||||
|
||||
if (componentID === 'body') {
|
||||
@ -257,7 +252,6 @@ class EditorScreen extends Component {
|
||||
tags: fields.tags,
|
||||
beneficiaries: getBeneficiaries(),
|
||||
rewardType,
|
||||
scheduledFor: scheduledFor ? scheduledFor : scheduledForDate,
|
||||
});
|
||||
const jsonMeta = makeJsonMetadata(meta, fields.tags);
|
||||
fields.meta = jsonMeta;
|
||||
@ -389,7 +383,6 @@ class EditorScreen extends Component {
|
||||
thumbIndex,
|
||||
uploadProgress,
|
||||
rewardType,
|
||||
scheduledForDate
|
||||
} = this.props;
|
||||
|
||||
const rightButtonText = intl.formatMessage({
|
||||
@ -491,7 +484,6 @@ class EditorScreen extends Component {
|
||||
isEdit={isEdit}
|
||||
isCommunityPost={selectedCommunity !== null}
|
||||
rewardType={rewardType}
|
||||
scheduledForDate={scheduledForDate}
|
||||
handleThumbSelection={this._handleOnThumbSelection}
|
||||
handleRewardChange={this._handleRewardChange}
|
||||
handleScheduleChange={this._handleScheduleChange}
|
||||
|
Loading…
Reference in New Issue
Block a user