Rely more on conditions for state derived after worktree changes

This commit is contained in:
Antonio Scandurra
2021-05-13 11:25:29 +02:00
parent 2c430668fc
commit 19f51bc480
3 changed files with 15 additions and 29 deletions
-14
View File
@@ -134,20 +134,6 @@ impl Worktree {
}
}
pub fn next_scan_complete(&self, ctx: &mut ModelContext<Self>) -> impl Future<Output = ()> {
let scan_id = self.snapshot.scan_id;
let mut scan_state = self.scan_state.1.clone();
ctx.spawn(|this, ctx| async move {
while let Some(scan_state) = scan_state.recv().await {
if this.read_with(&ctx, |this, _| {
matches!(scan_state, ScanState::Idle) && this.snapshot.scan_id > scan_id
}) {
break;
}
}
})
}
fn observe_scan_state(&mut self, scan_state: ScanState, ctx: &mut ModelContext<Self>) {
let _ = self.scan_state.0.blocking_send(scan_state);
self.poll_entries(ctx);