Skip to content

Commit 2bd7a05

Browse files
committed
feat: update headerSelectedIndex calculation to include active feed index
1 parent 9f5e338 commit 2bd7a05

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

app/Console/Commands/FeedCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,16 @@ private function renderFeed(User $user, Collection $posts, int $postsPerPage): v
139139

140140
$viewName = $this->activeFeed === 'profile' ? 'profile.index' : 'feed.index';
141141

142+
$feedKeys = ['following', 'trending', 'profile'];
143+
$activeFeedIndex = array_search($this->activeFeed, $feedKeys);
144+
142145
render(view($viewName, [
143146
'user' => $user,
144147
'posts' => $visiblePosts,
145148
'selectedIndex' => $postSelectedIndex !== null ? $postSelectedIndex - $this->scrollOffset : null,
146149
'totalPosts' => $posts->count(),
147150
'currentPosition' => $postSelectedIndex !== null ? $postSelectedIndex + 1 : null,
148-
'headerSelectedIndex' => $isHeaderSelected ? abs($this->selectedIndex) - 1 : null,
151+
'headerSelectedIndex' => $isHeaderSelected ? abs($this->selectedIndex) - 1 : $activeFeedIndex,
149152
'scrollOffset' => $this->scrollOffset,
150153
])->render());
151154
}

0 commit comments

Comments
 (0)