Skip to content

Commit

Permalink
Merge pull request #20184 from wordpress-mobile/issue-post-list-tab-s…
Browse files Browse the repository at this point in the history
…witching

Fixes: Issue post list tab switching
  • Loading branch information
zwarm authored Feb 14, 2024
2 parents c548dee + 81eb6e1 commit 333c1c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,18 @@ class PostListMainViewModel @Inject constructor(
}

fun handleEditPostResult(data: Intent?) {
switchToDraftTabIfNeeded(data)
postActionHandler.handleEditPostResult(data)
}

private fun switchToDraftTabIfNeeded(data: Intent?) {
if (data != null && data.getBooleanExtra(EditPostActivity.EXTRA_IS_NEW_POST, false) &&
data.getBooleanExtra(EditPostActivity.EXTRA_HAS_CHANGES, false)
) {
_selectTab.value = POST_LIST_PAGES.indexOf(DRAFTS)
}
}

private fun editRestoredAutoSavePost(localPostId: Int) {
val post = postStore.getPostByLocalPostId(localPostId)
if (post != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class PostsListActivity : LocaleAwareActivity(),
}
}

private fun setupActions() {
private fun PostListActivityBinding.setupActions() {
viewModel.dialogAction.observe(this@PostsListActivity) {
it?.show(this@PostsListActivity, supportFragmentManager, uiHelpers)
}
Expand All @@ -377,13 +377,18 @@ class PostsListActivity : LocaleAwareActivity(),
uploadActionUseCase,
uploadUtilsWrapper
) { isFirstTimePublishing ->
changeTabsOnPostUpload()
bloggingRemindersViewModel.onPublishingPost(site.id, isFirstTimePublishing)
reviewViewModel.onPublishingPost(isFirstTimePublishing)
}
}
}
}

private fun PostListActivityBinding.changeTabsOnPostUpload() {
tabLayout.getTabAt(PostListType.PUBLISHED.ordinal)?.select()
}

private fun PostListActivityBinding.loadViewState(state: PostListMainViewState) {
if (state.isFabVisible) {
fabButton.show()
Expand Down

0 comments on commit 333c1c7

Please sign in to comment.