updated recent draft load logic to support new draft deletion

This commit is contained in:
Nouman Tahir 2021-07-07 12:46:19 +05:00
parent 76db34e328
commit 207211c9f5

View File

@ -262,6 +262,7 @@ class EditorContainer extends Component {
const drafts = await getDrafts(username);
const idLessDraft = await getDraftPost(username);
const loadRecentDraft = () => {
//if no draft available means local draft is recent
if (drafts.length == 0) {
@ -277,7 +278,10 @@ class EditorContainer extends Component {
//if unsaved local draft is more latest then remote draft, use that instead
//if editor was opened from draft screens, this code will be skipped anyways.
if (idLessDraft && new Date(_draft.modified).getTime() < idLessDraft.timestamp) {
if ( idLessDraft
&& (idLessDraft.title !== '' || idLessDraft.tags !== '' || idLessDraft.body !== '')
&& new Date(_draft.modified).getTime() < idLessDraft.timestamp
) {
_getStorageDraftGeneral(false);
return;
}
@ -290,6 +294,8 @@ class EditorContainer extends Component {
this._getStorageDraft(username, isReply, _draft);
};
if (drafts.length > 0 || (idLessDraft && idLessDraft.timestamp > 0)) {
this.setState({
onLoadDraftPress: loadRecentDraft,