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 -> // Media select functions <- END ->
_handleOnSaveButtonPress = (fields) => { _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; const { isDraftSaved } = this.state;
if (!isDraftSaved) { if (!isDraftSaved) {
const { currentAccount } = this.props; const { currentAccount } = this.props;
@ -391,7 +416,7 @@ class EditorContainer extends Component {
} }
}; };
_handleOnPressBackButton= () =>{ _handleOnPressBackButton= () => {
alert("pressed"); alert("pressed");
} }
@ -418,21 +443,22 @@ class EditorContainer extends Component {
draftPost={draftPost} draftPost={draftPost}
handleFormChanged={this._handleFormChanged} handleFormChanged={this._handleFormChanged}
handleOnImagePicker={this._handleRoutingAction} handleOnImagePicker={this._handleRoutingAction}
handleOnPressBackButton={this._handleOnPressBackButton}
handleOnSaveButtonPress={this._handleOnSaveButtonPress} handleOnSaveButtonPress={this._handleOnSaveButtonPress}
handleOnSubmit={this._handleSubmit} handleOnSubmit={this._handleSubmit}
isCameraOrPickerOpen={isCameraOrPickerOpen} isCameraOrPickerOpen={isCameraOrPickerOpen}
isDarkTheme={isDarkTheme} isDarkTheme={isDarkTheme}
isDraftSaved={isDraftSaved} isDraftSaved={isDraftSaved}
isDraftSaving={isDraftSaving} isDraftSaving={isDraftSaving}
isEdit={isEdit}
isLoggedIn={isLoggedIn} isLoggedIn={isLoggedIn}
isOpenCamera={isOpenCamera} isOpenCamera={isOpenCamera}
isPostSending={isPostSending} isPostSending={isPostSending}
isReply={isReply} isReply={isReply}
isEdit={isEdit}
isUploading={isUploading} isUploading={isUploading}
post={post} post={post}
saveCurrentDraft={this._saveCurrentDraft}
uploadedImage={uploadedImage} uploadedImage={uploadedImage}
handleOnPressBackButton={this._handleOnPressBackButton}
/> />
); );
} }

View File

@ -74,6 +74,19 @@ class EditorScreen extends Component {
handleOnSaveButtonPress(fields); handleOnSaveButtonPress(fields);
}; };
_saveCurrentDraft = () => {
const { saveCurrentDraft } = this.props;
const { fields } = this.state;
if (this.changeTimer) {
clearTimeout(this.changeTimer);
}
this.changeTimer = setTimeout(() => {
saveCurrentDraft(fields);
}, 300);
};
_handleOnSubmit = () => { _handleOnSubmit = () => {
const { handleOnSubmit } = this.props; const { handleOnSubmit } = this.props;
const { fields } = this.state; const { fields } = this.state;
@ -117,6 +130,7 @@ class EditorScreen extends Component {
handleFormChanged(); handleFormChanged();
this._handleIsFormValid(); this._handleIsFormValid();
this._saveCurrentDraft();
}; };
_handleOnTagAdded = (tags) => { _handleOnTagAdded = (tags) => {