Skip to content

Commit

Permalink
+ Adds: the logic to switch to drafts tab when you add a new post
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeshRPai committed Feb 14, 2024
1 parent fc70d70 commit 81eb6e1
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 81eb6e1

Please sign in to comment.