mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 19:01:38 +03:00
updated recent draft load logic to support new draft deletion
This commit is contained in:
parent
76db34e328
commit
207211c9f5
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user