fix: fine tune git reload updates, fix lazy load underflow
Only refresh the git history on repo change events, seems to be a few other git store events that trigger lots of frequent changes Fix subtract with overflow Removes some extra clones
This commit is contained in:
parent
eb01cd2ad3
commit
efc009ee65
1 changed files with 10 additions and 12 deletions
|
@ -53,8 +53,10 @@ impl GitCommitList {
|
|||
this.reload_history(window, cx)
|
||||
}
|
||||
|
||||
// Reload the history for any other changes
|
||||
_ => this.reload_history(window, cx),
|
||||
// Reload the git history on repository changes to the current repo
|
||||
GitStoreEvent::RepositoryUpdated(_, _, true) => this.reload_history(window, cx),
|
||||
|
||||
_ => {}
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
|
@ -62,7 +64,10 @@ impl GitCommitList {
|
|||
let commits_list = ListState::new(0, gpui::ListAlignment::Top, px(1000.));
|
||||
commits_list.set_scroll_handler(cx.listener(
|
||||
|this: &mut Self, event: &ListScrollEvent, window, cx| {
|
||||
if event.visible_range.end >= this.commits.len() - 5 && this.has_next_page() {
|
||||
if this.commits.len() > 5
|
||||
&& event.visible_range.end >= this.commits.len() - 5
|
||||
&& this.has_next_page()
|
||||
{
|
||||
this.load_next_history_page(window, cx);
|
||||
}
|
||||
},
|
||||
|
@ -125,7 +130,7 @@ impl GitCommitList {
|
|||
author_email: commit.author_email.clone(),
|
||||
commit_time: OffsetDateTime::from_unix_timestamp(commit.commit_timestamp)?,
|
||||
message: Some(ParsedCommitMessage {
|
||||
message: commit.message.clone(),
|
||||
message: commit.message,
|
||||
..Default::default()
|
||||
}),
|
||||
})
|
||||
|
@ -209,7 +214,6 @@ impl GitCommitList {
|
|||
),
|
||||
)
|
||||
.on_click({
|
||||
let commit = commit_summary.clone();
|
||||
let workspace = self.workspace.clone();
|
||||
let repo = self.active_repository.as_ref().map(|repo| repo.downgrade());
|
||||
move |_, window, cx| {
|
||||
|
@ -217,13 +221,7 @@ impl GitCommitList {
|
|||
Some(repo) => repo,
|
||||
None => return,
|
||||
};
|
||||
CommitView::open(
|
||||
commit.clone(),
|
||||
repo.clone(),
|
||||
workspace.clone().clone(),
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
CommitView::open(commit_summary.clone(), repo, workspace.clone(), window, cx);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue