working on current save draft

This commit is contained in:
u-e 2019-01-07 17:55:58 +03:00
parent 4c8da5c9fd
commit 0191682c34
2 changed files with 44 additions and 4 deletions

View File

@ -213,6 +213,31 @@ class EditorContainer extends Component {
// Media select functions <- END ->
_handleOnSaveButtonPress = (fields) => {
// const { isDraftSaved } = this.state;
// if (!isDraftSaved) {
// const { currentAccount } = this.props;
// const username = currentAccount && currentAccount.name ? currentAccount.name : '';
// this.setState({ isDraftSaving: true });
// const draftField = {
// ...fields,
// tags: fields.tags.toString(),
// };
// setDraftPost(draftField, username)
// .then(() => {
// this.setState({
// isDraftSaving: false,
// isDraftSaved: true,
// });
// })
// .catch((error) => {
// alert(error);
// });
// }
};
_saveCurrentDraft = (fields) => {
const { isDraftSaved } = this.state;
if (!isDraftSaved) {
const { currentAccount } = this.props;
@ -391,7 +416,7 @@ class EditorContainer extends Component {
}
};
_handleOnPressBackButton= () =>{
_handleOnPressBackButton= () => {
alert("pressed");
}
@ -418,21 +443,22 @@ class EditorContainer extends Component {
draftPost={draftPost}
handleFormChanged={this._handleFormChanged}
handleOnImagePicker={this._handleRoutingAction}
handleOnPressBackButton={this._handleOnPressBackButton}
handleOnSaveButtonPress={this._handleOnSaveButtonPress}
handleOnSubmit={this._handleSubmit}
isCameraOrPickerOpen={isCameraOrPickerOpen}
isDarkTheme={isDarkTheme}
isDraftSaved={isDraftSaved}
isDraftSaving={isDraftSaving}
isEdit={isEdit}
isLoggedIn={isLoggedIn}
isOpenCamera={isOpenCamera}
isPostSending={isPostSending}
isReply={isReply}
isEdit={isEdit}
isUploading={isUploading}
post={post}
saveCurrentDraft={this._saveCurrentDraft}
uploadedImage={uploadedImage}
handleOnPressBackButton={this._handleOnPressBackButton}
/>
);
}

View File

@ -74,6 +74,19 @@ class EditorScreen extends Component {
handleOnSaveButtonPress(fields);
};
_saveCurrentDraft = () => {
const { saveCurrentDraft } = this.props;
const { fields } = this.state;
if (this.changeTimer) {
clearTimeout(this.changeTimer);
}
this.changeTimer = setTimeout(() => {
saveCurrentDraft(fields);
}, 300);
};
_handleOnSubmit = () => {
const { handleOnSubmit } = this.props;
const { fields } = this.state;
@ -117,6 +130,7 @@ class EditorScreen extends Component {
handleFormChanged();
this._handleIsFormValid();
this._saveCurrentDraft();
};
_handleOnTagAdded = (tags) => {
@ -147,7 +161,7 @@ class EditorScreen extends Component {
handleOnPressBackButton,
} = this.props;
const rightButtonText = intl.formatMessage({
id: isEdit ? 'basic_header.update' : isReply ? 'basic_header.reply' : 'basic_header.publish',
id: isEdit ? 'basic_header.update' : isReply ? 'basic_header.reply' : 'basic_header.publish',
});
return (