-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce GutenbergEditPostActivity #8874
Changes from all commits
a49bc70
74765be
13d3d75
79eef32
ae235ce
2ccd179
2f8ef0e
d008ed1
5e1c762
f3f4ee9
85263bb
9656247
5dbdfce
ea3d415
fbd314b
fd181f2
dd4211e
87fae7e
7ad4619
e30b4d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ import org.wordpress.android.ui.RequestCodes | |
import org.wordpress.android.ui.WPWebViewActivity | ||
import org.wordpress.android.ui.pages.PageItem.Page | ||
import org.wordpress.android.ui.posts.BasicFragmentDialog | ||
import org.wordpress.android.ui.posts.EditPostActivity | ||
import org.wordpress.android.ui.posts.EditPostBaseActivity | ||
import org.wordpress.android.ui.posts.GutenbergWarningFragmentDialog.GutenbergWarningDialogClickInterface | ||
import org.wordpress.android.ui.posts.PostUtils | ||
import org.wordpress.android.ui.prefs.AppPrefs | ||
|
@@ -90,7 +90,7 @@ class PagesFragment : Fragment(), GutenbergWarningDialogClickInterface { | |
|
||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | ||
if (requestCode == RequestCodes.EDIT_POST && resultCode == Activity.RESULT_OK && data != null) { | ||
val pageId = data.getLongExtra(EditPostActivity.EXTRA_POST_REMOTE_ID, -1) | ||
val pageId = data.getLongExtra(EditPostBaseActivity.EXTRA_POST_REMOTE_ID, -1) | ||
if (pageId != -1L) { | ||
onPageEditFinished(pageId) | ||
} | ||
|
@@ -246,13 +246,17 @@ class PagesFragment : Fragment(), GutenbergWarningDialogClickInterface { | |
viewModel.editPage.observe(this, Observer { page -> | ||
page?.let { | ||
val post = postStore.getPostByLocalPostId(page.pageId) | ||
val isGutenbergContent = PostUtils.contentContainsGutenbergBlocks(post?.content) | ||
if (isGutenbergContent && !AppPrefs.isGutenbergWarningDialogDisabled()) { | ||
PostUtils.showGutenbergCompatibilityWarningDialog( | ||
getActivity(), fragmentManager, post, viewModel.site | ||
) | ||
if (PostUtils.shouldShowGutenbergEditor(false, post)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels to me that the check for Gutenberg editor is bleeding into this class ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment above |
||
ActivityLauncher.editPageForResultOnGutenberg(this, page) | ||
} else { | ||
ActivityLauncher.editPageForResult(this, page) | ||
val isGutenbergContent = PostUtils.contentContainsGutenbergBlocks(post?.content) | ||
if (isGutenbergContent && !AppPrefs.isGutenbergWarningDialogDisabled()) { | ||
PostUtils.showGutenbergCompatibilityWarningDialog( | ||
getActivity(), fragmentManager, post, viewModel.site | ||
) | ||
} else { | ||
ActivityLauncher.editPageForResult(this, page) | ||
} | ||
} | ||
} | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, having a Gutenberg-dedicated method (
editPageForResultOnGutenberg
) is generally fine but, only a few lines above (line 605) we're seeing a different pattern, where the method is just one and it it decides internally which editor to launch. Can we get away with using just one of the two patterns perhaps?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine for this case as otherwise we need to inject and use FluxC in ActivityLauncher just to be able to inflate the PageModel, read the content of the Post body and then only decide which Activity to launch. This, in the only case where this method is called, is already known at the time the call happens by the caller.