mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 21:01:31 +03:00
updated for remove reply
This commit is contained in:
parent
d4f7911437
commit
29830ee54f
@ -118,7 +118,7 @@ class EditorContainer extends Component {
|
||||
});
|
||||
} else {
|
||||
await getDraftPost(username)
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
this.setState({
|
||||
draftPost: { body: result.body, title: result.title, tags: result.tags.split(',') },
|
||||
});
|
||||
@ -127,13 +127,11 @@ class EditorContainer extends Component {
|
||||
// alert(error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
_getPurePost = (author, permlink) => {
|
||||
getPurePost(author, permlink)
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
if (result) {
|
||||
this.setState(prevState => ({
|
||||
draftPost: {
|
||||
@ -146,7 +144,7 @@ class EditorContainer extends Component {
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
_handleRoutingAction = (routingAction) => {
|
||||
_handleRoutingAction = routingAction => {
|
||||
this.setState({ isCameraOrPickerOpen: true });
|
||||
|
||||
if (routingAction === 'camera') {
|
||||
@ -162,10 +160,10 @@ class EditorContainer extends Component {
|
||||
ImagePicker.openPicker({
|
||||
includeBase64: true,
|
||||
})
|
||||
.then((image) => {
|
||||
.then(image => {
|
||||
this._handleMediaOnSelected(image);
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch(e => {
|
||||
this._handleMediaOnSelectFailure(e);
|
||||
});
|
||||
};
|
||||
@ -174,15 +172,15 @@ class EditorContainer extends Component {
|
||||
ImagePicker.openCamera({
|
||||
includeBase64: true,
|
||||
})
|
||||
.then((image) => {
|
||||
.then(image => {
|
||||
this._handleMediaOnSelected(image);
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch(e => {
|
||||
this._handleMediaOnSelectFailure(e);
|
||||
});
|
||||
};
|
||||
|
||||
_handleMediaOnSelected = (media) => {
|
||||
_handleMediaOnSelected = media => {
|
||||
this.setState({ isCameraOrPickerOpen: false, isUploading: true }, () => {
|
||||
this._uploadImage(media);
|
||||
});
|
||||
@ -194,7 +192,7 @@ class EditorContainer extends Component {
|
||||
// const data = new Buffer(media.data, 'base64');
|
||||
};
|
||||
|
||||
_uploadImage = (media) => {
|
||||
_uploadImage = media => {
|
||||
const { intl } = this.props;
|
||||
|
||||
const file = {
|
||||
@ -205,12 +203,12 @@ class EditorContainer extends Component {
|
||||
};
|
||||
|
||||
uploadImage(file)
|
||||
.then((res) => {
|
||||
.then(res => {
|
||||
if (res.data && res.data.url) {
|
||||
this.setState({ uploadedImage: res.data, isUploading: false });
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(error => {
|
||||
Alert.alert(
|
||||
intl.formatMessage({
|
||||
id: 'alert.fail',
|
||||
@ -221,7 +219,7 @@ class EditorContainer extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
_handleMediaOnSelectFailure = (error) => {
|
||||
_handleMediaOnSelectFailure = error => {
|
||||
const { intl } = this.props;
|
||||
this.setState({ isCameraOrPickerOpen: false });
|
||||
|
||||
@ -239,7 +237,7 @@ class EditorContainer extends Component {
|
||||
|
||||
// Media select functions <- END ->
|
||||
|
||||
_saveDraftToDB = (fields) => {
|
||||
_saveDraftToDB = fields => {
|
||||
const { isDraftSaved, draftId } = this.state;
|
||||
if (!isDraftSaved) {
|
||||
const { currentAccount } = this.props;
|
||||
@ -259,7 +257,7 @@ class EditorContainer extends Component {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
addDraft(draftField).then((response) => {
|
||||
addDraft(draftField).then(response => {
|
||||
this.setState({
|
||||
isDraftSaved: true,
|
||||
draftId: response._id,
|
||||
@ -273,7 +271,7 @@ class EditorContainer extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_saveCurrentDraft = async (fields) => {
|
||||
_saveCurrentDraft = async fields => {
|
||||
const { draftId, isReply } = this.state;
|
||||
|
||||
if (!draftId) {
|
||||
@ -293,10 +291,8 @@ class EditorContainer extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_submitPost = async (fields) => {
|
||||
const {
|
||||
navigation, currentAccount, pinCode, intl,
|
||||
} = this.props;
|
||||
_submitPost = async fields => {
|
||||
const { navigation, currentAccount, pinCode, intl } = this.props;
|
||||
|
||||
if (currentAccount) {
|
||||
this.setState({ isPostSending: true });
|
||||
@ -355,13 +351,13 @@ class EditorContainer extends Component {
|
||||
|
||||
setDraftPost({ title: '', body: '', tags: [] }, currentAccount.name);
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(error => {
|
||||
this._handleSubmitFailure(error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_submitReply = async (fields) => {
|
||||
_submitReply = async fields => {
|
||||
const { currentAccount, pinCode } = this.props;
|
||||
|
||||
if (currentAccount) {
|
||||
@ -390,14 +386,15 @@ class EditorContainer extends Component {
|
||||
)
|
||||
.then(() => {
|
||||
this._handleSubmitSuccess();
|
||||
AsyncStorage.setItem('temp-reply', "");
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(error => {
|
||||
this._handleSubmitFailure(error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_submitEdit = async (fields) => {
|
||||
_submitEdit = async fields => {
|
||||
const { currentAccount, pinCode } = this.props;
|
||||
const { post } = this.state;
|
||||
if (currentAccount) {
|
||||
@ -435,13 +432,13 @@ class EditorContainer extends Component {
|
||||
.then(() => {
|
||||
this._handleSubmitSuccess();
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(error => {
|
||||
this._handleSubmitFailure(error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_handleSubmitFailure = (error) => {
|
||||
_handleSubmitFailure = error => {
|
||||
const { intl } = this.props;
|
||||
|
||||
Alert.alert(
|
||||
@ -469,7 +466,7 @@ class EditorContainer extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleSubmit = (form) => {
|
||||
_handleSubmit = form => {
|
||||
const { isReply, isEdit } = this.state;
|
||||
|
||||
if (isReply && !isEdit) {
|
||||
|
Loading…
Reference in New Issue
Block a user