Make replica_id optional in OpenWorktreeResponse

This commit is contained in:
Antonio Scandurra 2021-06-23 17:32:05 +02:00
parent 02321af08a
commit f1587fbb6e
2 changed files with 12 additions and 3 deletions

View file

@ -43,7 +43,7 @@ message OpenWorktree {
message OpenWorktreeResponse {
Worktree worktree = 1;
uint32 replica_id = 2;
optional uint32 replica_id = 2;
}
message AddGuest {

View file

@ -766,12 +766,21 @@ impl Workspace {
let worktree = open_worktree_response
.worktree
.ok_or_else(|| anyhow!("empty worktree"))?;
let replica_id = open_worktree_response.replica_id as ReplicaId;
let replica_id = open_worktree_response
.replica_id
.ok_or_else(|| anyhow!("empty replica id"))?;
let worktree_id = worktree_id.try_into().unwrap();
this.update(&mut cx, |workspace, cx| {
let worktree = cx.add_model(|cx| {
Worktree::remote(worktree_id, worktree, rpc, connection_id, replica_id, cx)
Worktree::remote(
worktree_id,
worktree,
rpc,
connection_id,
replica_id as ReplicaId,
cx,
)
});
cx.observe_model(&worktree, |_, _, cx| cx.notify());
workspace.worktrees.insert(worktree);