mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-10 20:29:05 +00:00
Merge pull request #1206 from zed-industries/fix-offline-project-leak
Fix project leak in contacts panel
This commit is contained in:
commit
4bb5a2f19e
1 changed files with 11 additions and 14 deletions
|
@ -508,18 +508,12 @@ impl ContactsPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_offline_project(
|
fn render_offline_project(
|
||||||
project: WeakModelHandle<Project>,
|
project_handle: WeakModelHandle<Project>,
|
||||||
theme: &theme::ContactsPanel,
|
theme: &theme::ContactsPanel,
|
||||||
tooltip_style: &TooltipStyle,
|
tooltip_style: &TooltipStyle,
|
||||||
is_selected: bool,
|
is_selected: bool,
|
||||||
cx: &mut RenderContext<Self>,
|
cx: &mut RenderContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
let project = if let Some(project) = project.upgrade(cx.deref_mut()) {
|
|
||||||
project
|
|
||||||
} else {
|
|
||||||
return Empty::new().boxed();
|
|
||||||
};
|
|
||||||
|
|
||||||
let host_avatar_height = theme
|
let host_avatar_height = theme
|
||||||
.contact_avatar
|
.contact_avatar
|
||||||
.width
|
.width
|
||||||
|
@ -529,13 +523,17 @@ impl ContactsPanel {
|
||||||
enum LocalProject {}
|
enum LocalProject {}
|
||||||
enum ToggleOnline {}
|
enum ToggleOnline {}
|
||||||
|
|
||||||
let project_id = project.id();
|
let project_id = project_handle.id();
|
||||||
MouseEventHandler::new::<LocalProject, _, _>(project_id, cx, |state, cx| {
|
MouseEventHandler::new::<LocalProject, _, _>(project_id, cx, |state, cx| {
|
||||||
let row = theme.project_row.style_for(state, is_selected);
|
let row = theme.project_row.style_for(state, is_selected);
|
||||||
let mut worktree_root_names = String::new();
|
let mut worktree_root_names = String::new();
|
||||||
let project_ = project.read(cx);
|
let project = if let Some(project) = project_handle.upgrade(cx.deref_mut()) {
|
||||||
let is_going_online = project_.is_online();
|
project.read(cx)
|
||||||
for tree in project_.visible_worktrees(cx) {
|
} else {
|
||||||
|
return Empty::new().boxed();
|
||||||
|
};
|
||||||
|
let is_going_online = project.is_online();
|
||||||
|
for tree in project.visible_worktrees(cx) {
|
||||||
if !worktree_root_names.is_empty() {
|
if !worktree_root_names.is_empty() {
|
||||||
worktree_root_names.push_str(", ");
|
worktree_root_names.push_str(", ");
|
||||||
}
|
}
|
||||||
|
@ -563,9 +561,8 @@ impl ContactsPanel {
|
||||||
button
|
button
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.on_click(move |_, _, cx| {
|
.on_click(move |_, _, cx| {
|
||||||
cx.dispatch_action(ToggleProjectOnline {
|
let project = project_handle.upgrade(cx.deref_mut());
|
||||||
project: Some(project.clone()),
|
cx.dispatch_action(ToggleProjectOnline { project })
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.with_tooltip::<ToggleOnline, _>(
|
.with_tooltip::<ToggleOnline, _>(
|
||||||
project_id,
|
project_id,
|
||||||
|
|
Loading…
Reference in a new issue