This commit is contained in:
u-e 2019-01-07 17:00:15 +03:00
parent 7db25ce708
commit 6370da65e4
4 changed files with 29 additions and 13 deletions

View File

@ -22,7 +22,7 @@ class BasicHeaderContainer extends Component {
// Component Functions
_handleOnPressBackButton = () => {
const { navigation, isNewPost } = this.props;
const { navigation, isNewPost, handleOnPressBackButton } = this.props;
if (isNewPost) {
navigation.navigate({
@ -31,6 +31,8 @@ class BasicHeaderContainer extends Component {
} else {
navigation.goBack();
}
if (handleOnPressBackButton) handleOnPressBackButton();
};
render() {

View File

@ -5,7 +5,7 @@ import serverList from '../../config/serverListApi';
export const getDrafts = data => new Promise((resolve, reject) => {
api
.get(`/drafts/${data.user}`)
.get(`/drafts/${data.username}`)
.then((res) => {
resolve(res.data);
})

View File

@ -92,18 +92,22 @@ class EditorContainer extends Component {
}
if (!isReply && !isEdit) {
getDraftPost(username)
.then((result) => {
this.setState({
draftPost: { body: result.body, title: result.title, tags: result.tags.split(',') },
});
})
.catch((error) => {
// alert(error);
});
this._getDraft(username);
}
}
_getDraft = (username) => {
getDraftPost(username)
.then((result) => {
this.setState({
draftPost: { body: result.body, title: result.title, tags: result.tags.split(',') },
});
})
.catch((error) => {
// alert(error);
});
};
_getPurePost = (author, permlink) => {
getPurePost(author, permlink)
.then((result) => {
@ -320,7 +324,10 @@ class EditorContainer extends Component {
this.setState({ isPostSending: true });
const {
body: oldBody, parent_permlink: parentPermlink, permlink, parent_author: parentAuthor,
body: oldBody,
parent_permlink: parentPermlink,
permlink,
parent_author: parentAuthor,
} = post;
let newBody = fields.body;
@ -384,6 +391,10 @@ class EditorContainer extends Component {
}
};
_handleOnPressBackButton= () =>{
alert("pressed");
}
render() {
const { isLoggedIn, isDarkTheme } = this.props;
const {
@ -421,6 +432,7 @@ class EditorContainer extends Component {
isUploading={isUploading}
post={post}
uploadedImage={uploadedImage}
handleOnPressBackButton={this._handleOnPressBackButton}
/>
);
}

View File

@ -132,6 +132,7 @@ class EditorScreen extends Component {
fields, isPreviewActive, wordsCount, isFormValid,
} = this.state;
const {
draftPost,
handleOnImagePicker,
intl,
isDraftSaved,
@ -143,7 +144,7 @@ class EditorScreen extends Component {
isUploading,
post,
uploadedImage,
draftPost
handleOnPressBackButton,
} = this.props;
const rightButtonText = intl.formatMessage({
id: isEdit ? 'basic_header.update' : isReply ? 'basic_header.reply' : 'basic_header.publish',
@ -155,6 +156,7 @@ class EditorScreen extends Component {
handleOnPressPreviewButton={this._handleOnPressPreviewButton}
handleOnSaveButtonPress={this._handleOnSaveButtonPress}
handleOnSubmit={this._handleOnSubmit}
handleOnPressBackButton={handleOnPressBackButton}
isDraftSaved={isDraftSaved}
isDraftSaving={isDraftSaving}
isFormValid={isFormValid}