Skip to content

Commit

Permalink
fix: Show scheduled posts after "Drafts" in the main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nikclayton committed Feb 5, 2025
1 parent f5d42c8 commit 6b50953
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/src/main/java/app/pachli/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -824,19 +824,21 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
// account list is open (https://github.com/mikepenz/MaterialDrawer/issues/2826).
// Instead, pull the position from the adapter for primary items. This is offset
// by 1 in the adapter that wraps all the items.
val existingPosition = binding.mainDrawer.itemAdapter.getAdapterPosition(DRAWER_ITEM_SCHEDULED_POSTS) + 1
val existingPosition = binding.mainDrawer.itemAdapter.getAdapterPosition(DRAWER_ITEM_SCHEDULED_POSTS)

val showing = existingPosition != 0
val showing = existingPosition != -1
if (showing == showSchedulePosts) return

if (!showSchedulePosts) {
binding.mainDrawer.removeItemByPosition(existingPosition)
binding.mainDrawer.itemAdapter.removeByIdentifier(DRAWER_ITEM_SCHEDULED_POSTS)
return
}

// Add the "Scheduled posts" item immediately after "Drafts"
binding.mainDrawer.addItemsAtPosition(
existingPosition + 1,
val relativeDraftsPosition = binding.mainDrawer.itemAdapter.getAdapterPosition(DRAWER_ITEM_DRAFTS)
val globalDraftsPosition = binding.mainDrawer.itemAdapter.getGlobalPosition(relativeDraftsPosition)
binding.mainDrawer.itemAdapter.add(
globalDraftsPosition + 1,
primaryDrawerItem {
identifier = DRAWER_ITEM_SCHEDULED_POSTS
nameRes = R.string.action_access_scheduled_posts
Expand Down

0 comments on commit 6b50953

Please sign in to comment.