Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 1 addition & 42 deletions app/src/code_review/code_review_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2422,52 +2422,11 @@ impl CodeReviewView {

fn handle_diff_state_model_event(
&mut self,
diff_state_model: ModelHandle<DiffStateModel>,
_diff_state_model: ModelHandle<DiffStateModel>,
event: &DiffStateModelEvent,
ctx: &mut ViewContext<Self>,
) {
match event {
DiffStateModelEvent::RepositoryChanged => {
let old_path = self.repo_path().cloned();
let repo_path =
diff_state_model.read(ctx, |model, _| model.active_repository_path(ctx));

safe_info!(
safe: ("Code Review: Repository changed. Branch list cleared."),
full: (
"Code Review: Repository changed event - old path: {:?}, new path: {:?}",
old_path,
repo_path
)
);

// Abort in-flight file invalidation tasks on the old repo before
// it is potentially replaced.
self.queue_full_invalidation();

if self.repo_path() != repo_path.as_ref() {
self.update_current_repo(repo_path.clone(), ctx);
}

// update_current_repo replaces active_repo with a fresh
// RepositoryState, discarding the invalidate_all_pending flag
// that queue_full_invalidation just set. Re-apply it so the
// new repo also defers file invalidations until the full reload
// completes. (state == None covers this today, but the explicit
// flag makes the invariant resilient to future changes.)
if let Some(repo) = self.active_repo.as_mut() {
repo.file_invalidation.invalidate_all_pending = true;
}

let repo_path_for_list = repo_path.clone().unwrap_or_default();
self.comment_list_view.update(ctx, |view, ctx| {
// TODO(alokedesai): Update how we model repo path so that it's optional.
// There are no guarantees that CodeReviewView is within a repo.
view.set_repo_path(repo_path_for_list.clone(), ctx);
});

self.invalidate_all(None, ctx);
}
DiffStateModelEvent::DiffMetadataChanged(InvalidationBehavior::All(source)) => {
// If the invalidation is an index lock change AND we don't have an already pending invalidation,
// don't eagerly reload all of the diffs.
Expand Down
2 changes: 1 addition & 1 deletion app/src/code_review/code_review_view_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl TestContext {
let (window_id, _) = app.add_window(WindowStyle::NotStealFocus, |_| TestView);
let state = create_loaded_state_with_editors(app, window_id, vec![(file_path, editor)]);

let diff_state_model = app.add_model(|ctx| DiffStateModel::new(None, ctx));
let diff_state_model = app.add_model(|ctx| DiffStateModel::new_for_test(ctx));

let working_directories_model = app.add_model(|_| WorkingDirectoriesModel::new());
let code_review_comment_batch =
Expand Down
8 changes: 0 additions & 8 deletions app/src/code_review/comment_list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,6 @@ impl CommentListView {
ctx.notify();
}

pub fn set_repo_path(&mut self, repo_path: PathBuf, ctx: &mut ViewContext<Self>) {
self.repo_path = repo_path;
for state in self.comments_by_id.values_mut() {
state.card.update_title(Some(&self.repo_path));
}
ctx.notify();
}

pub fn expand(&mut self, ctx: &mut ViewContext<Self>) {
if self.is_collapsed {
self.is_collapsed = false;
Expand Down
5 changes: 0 additions & 5 deletions app/src/code_review/comment_rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,6 @@ impl CommentViewCard {
matches!(self.diff_content, Some(CommentDiffContent::EditorLens))
}

/// Recomputes the cached display title.
pub(crate) fn update_title(&mut self, repo_path: Option<&Path>) {
self.title = Self::compute_title(&self.source, repo_path);
}

/// Refreshes the cached `last_updated_duration` to the current time.
pub(crate) fn refresh_last_updated_duration(&mut self) {
self.last_updated_duration = Local::now() - self.source.last_update_time;
Expand Down
Loading
Loading