Skip to content

Commit

Permalink
Don't force focus the PR details when preloading
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo385 committed Jan 28, 2025
1 parent 514009e commit 717051a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lazy_github/lib/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class PullRequestSelected(Message):
A message indicating that the user is looking for additional information on a particular pull request.
"""

def __init__(self, pr: PartialPullRequest) -> None:
self.pr = pr
def __init__(self, pr: PartialPullRequest, focus_pr_details: bool = True) -> None:
super().__init__()
self.pr = pr
self.focus_pr_details = focus_pr_details


class IssueSelected(Message):
Expand Down
7 changes: 4 additions & 3 deletions lazy_github/ui/screens/primary.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,16 @@ def details(self) -> SelectionDetailsContainer:
async def load_repository(self, repo: Repository) -> None:
await self.selections.load_repository(repo)

async def load_pull_request(self, pull_request: PartialPullRequest) -> None:
async def load_pull_request(self, pull_request: PartialPullRequest, focus_pr_details: bool = True) -> None:
full_pr = await get_full_pull_request(pull_request.repo, pull_request.number)
tabbed_content = self.query_one("#selection_detail_tabs", TabbedContent)
await tabbed_content.clear_panes()
await tabbed_content.add_pane(PrOverviewTabPane(full_pr))
await tabbed_content.add_pane(PrDiffTabPane(full_pr))
await tabbed_content.add_pane(PrConversationTabPane(full_pr))
tabbed_content.children[0].focus()
self.details.border_title = f"[5] PR #{full_pr.number} Details"
if focus_pr_details:
tabbed_content.children[0].focus()

async def load_issue(self, issue: Issue) -> None:
tabbed_content = self.query_one("#selection_detail_tabs", TabbedContent)
Expand All @@ -307,7 +308,7 @@ async def load_issue(self, issue: Issue) -> None:

@on(PullRequestSelected)
async def handle_pull_request_selection(self, message: PullRequestSelected) -> None:
await self.load_pull_request(message.pr)
await self.load_pull_request(message.pr, message.focus_pr_details)

@on(IssueSelected)
async def handle_issue_selection(self, message: IssueSelected) -> None:
Expand Down
2 changes: 1 addition & 1 deletion lazy_github/ui/widgets/pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def load_pull_request_for_current_commit(self) -> None:
associated_prs = await list_pull_requests_for_commit(LazyGithubContext.current_local_commit)
if len(associated_prs) == 1:
lg.info("Loading PR for your current commit")
self.post_message(PullRequestSelected(associated_prs[0]))
self.post_message(PullRequestSelected(associated_prs[0], False))

async def get_selected_pr(self) -> PartialPullRequest:
pr_number_coord = Coordinate(self.table.cursor_row, self.number_column_index)
Expand Down

0 comments on commit 717051a

Please sign in to comment.