From 0d8cb3106ed927137aefa47439f2510c0164da79 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 6 Apr 2021 01:37:03 +0500 Subject: [PATCH 1/3] added image delete confirmation alert --- .../uploadsGalleryModal/uploadsGalleryModal.tsx | 16 +++++++++++++++- src/config/locales/en-US.json | 6 +++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx b/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx index 8836f63d0..a72dd57f7 100644 --- a/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx +++ b/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx @@ -116,7 +116,21 @@ export const UploadsGalleryModal = forwardRef(({username, handleOnSelect, handl } const _onRemovePress = async () => { - _deleteMediaItem(item._id) + const _onConfirm = () => { + _deleteMediaItem(item._id) + } + Alert.alert( + intl.formatMessage({id:'uploads_modal.alert_remove_title'}), + intl.formatMessage({id:'uploads_modal.alert_remove_body'}), + [{ + text:intl.formatMessage({id:'uploads_modal.alert_btn_no'}), + style:'cancel' + },{ + text:intl.formatMessage({id:'uploads_modal.alert_btn_yes'}), + onPress:_onConfirm + }] + ) + } const thumbUrl = proxifyImageSrc(item.url, 600, 500, Platform.OS === 'ios' ? 'match' : 'webp'); diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 93dc61248..6cdda2603 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -337,7 +337,11 @@ "title_remove_confirmation":"Delete image", "btn_add":"Image", "message_failed":"Failed to upload image", - "message_remove_confirmation":"Are you sure you want to delete this image?" + "message_remove_confirmation":"Are you sure you want to delete this image?", + "alert_remove_title":"Confirm Delete", + "alert_remove_body":"Are you sure you wish to delete this image?", + "alert_btn_yes":"Yes", + "alert_btn_no":"No" }, "pincode": { "enter_text": "Enter PIN to unlock", From c71a59b041f2e8a86c4cd9d9ed17f4389baf8977 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Wed, 7 Apr 2021 18:32:35 +0500 Subject: [PATCH 2/3] ignoring post edits for local save, fixed toastNotification cache issue --- .../container/applicationContainer.js | 3 +++ .../editor/container/editorContainer.js | 27 ++++++++++--------- src/screens/editor/screen/editorScreen.js | 4 +-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index 1d5a27c37..67c4fb3f2 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -621,7 +621,10 @@ class ApplicationContainer extends Component { _getSettings = async () => { const { dispatch } = this.props; + //reset certain properties dispatch(hideActionModal()); + dispatch(toastNotification('')); + const settings = await getSettings(); if (settings) { diff --git a/src/screens/editor/container/editorContainer.js b/src/screens/editor/container/editorContainer.js index 4e22e7f4d..c5cc018f0 100644 --- a/src/screens/editor/container/editorContainer.js +++ b/src/screens/editor/container/editorContainer.js @@ -594,6 +594,11 @@ class EditorContainer extends Component { _saveCurrentDraft = async (fields) => { const { draftId, isReply, isEdit, isPostSending } = this.state; + //skip draft save in case post is sending or is post beign edited + if (isPostSending || isEdit) { + return; + } + const { currentAccount } = this.props; const username = currentAccount && currentAccount.name ? currentAccount.name : ''; @@ -602,20 +607,18 @@ class EditorContainer extends Component { tags: fields.tags && fields.tags.length > 0 ? fields.tags.toString() : '', }; - if (!isPostSending) { - //save reply data - if (isReply && draftField.body !== null) { - await AsyncStorage.setItem('temp-reply', draftField.body); + //save reply data + if (isReply && draftField.body !== null) { + await AsyncStorage.setItem('temp-reply', draftField.body); - //save existing draft data locally - } else if (draftId) { - setDraftPost(draftField, username, draftId); - } + //save existing draft data locally + } else if (draftId) { + setDraftPost(draftField, username, draftId); + } - //update editor data locally - else if (!isReply) { - setDraftPost(draftField, username); - } + //update editor data locally + else if (!isReply) { + setDraftPost(draftField, username); } }; diff --git a/src/screens/editor/screen/editorScreen.js b/src/screens/editor/screen/editorScreen.js index d47f29792..e173ba9f4 100644 --- a/src/screens/editor/screen/editorScreen.js +++ b/src/screens/editor/screen/editorScreen.js @@ -66,8 +66,8 @@ class EditorScreen extends Component { } componentWillUnmount() { - const { isReply } = this.props; - if (!isReply) { + const { isReply, isEdit } = this.props; + if (!isReply && !isEdit) { this._saveDraftToDB(); } } From 09a116e1b6c9775302979a85e237efe6155b6bec Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Wed, 7 Apr 2021 18:39:18 +0500 Subject: [PATCH 3/3] reusing pre-translated alert texts --- .../uploadsGalleryModal/uploadsGalleryModal.tsx | 8 ++++---- src/config/locales/en-US.json | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx b/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx index a72dd57f7..29cdb069c 100644 --- a/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx +++ b/src/components/uploadsGalleryModal/uploadsGalleryModal.tsx @@ -120,13 +120,13 @@ export const UploadsGalleryModal = forwardRef(({username, handleOnSelect, handl _deleteMediaItem(item._id) } Alert.alert( - intl.formatMessage({id:'uploads_modal.alert_remove_title'}), - intl.formatMessage({id:'uploads_modal.alert_remove_body'}), + intl.formatMessage({id:'alert.delete'}), + intl.formatMessage({id:'alert.remove_alert'}), [{ - text:intl.formatMessage({id:'uploads_modal.alert_btn_no'}), + text:intl.formatMessage({id:'alert.cancel'}), style:'cancel' },{ - text:intl.formatMessage({id:'uploads_modal.alert_btn_yes'}), + text:intl.formatMessage({id:'alert.confirm'}), onPress:_onConfirm }] ) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 6cdda2603..6cdfd795c 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -336,12 +336,7 @@ "title":"Uploaded Images", "title_remove_confirmation":"Delete image", "btn_add":"Image", - "message_failed":"Failed to upload image", - "message_remove_confirmation":"Are you sure you want to delete this image?", - "alert_remove_title":"Confirm Delete", - "alert_remove_body":"Are you sure you wish to delete this image?", - "alert_btn_yes":"Yes", - "alert_btn_no":"No" + "message_failed":"Failed to upload image" }, "pincode": { "enter_text": "Enter PIN to unlock",