diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt index 6933c9c0bf12..3e7fe716c570 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.kt @@ -3813,7 +3813,12 @@ class EditPostActivity : LocaleAwareActivity(), EditorFragmentActivity, EditorIm @Subscribe(threadMode = ThreadMode.MAIN) fun onPostUploaded(event: OnPostUploaded) { val post: PostModel? = event.post - if (post != null && post.id == editPostRepository.id) { + + // Check if editPostRepository is initialized + val editPostRepositoryInitialized = this::editPostRepository.isInitialized + val editPostId = if (editPostRepositoryInitialized) editPostRepository.getPost()?.id else null + + if (post != null && post.id == editPostId) { if (!isRemotePreviewingFromEditor) { // We are not remote previewing a post: show snackbar and update post status if needed val snackbarAttachView = findViewById(R.id.editor_activity)