Make collaboration warning more useful

This commit is contained in:
Conrad Irwin 2023-10-11 09:45:57 -06:00
parent 76191fe47d
commit 2d6725a41a

View file

@ -2,6 +2,7 @@ use crate::{
contact_notification::ContactNotification, face_pile::FacePile, toggle_deafen, toggle_mute, contact_notification::ContactNotification, face_pile::FacePile, toggle_deafen, toggle_mute,
toggle_screen_sharing, LeaveCall, ToggleDeafen, ToggleMute, ToggleScreenSharing, toggle_screen_sharing, LeaveCall, ToggleDeafen, ToggleMute, ToggleScreenSharing,
}; };
use auto_update::AutoUpdateStatus;
use call::{ActiveCall, ParticipantLocation, Room}; use call::{ActiveCall, ParticipantLocation, Room};
use client::{proto::PeerId, Client, ContactEventKind, SignIn, SignOut, User, UserStore}; use client::{proto::PeerId, Client, ContactEventKind, SignIn, SignOut, User, UserStore};
use clock::ReplicaId; use clock::ReplicaId;
@ -1177,22 +1178,38 @@ impl CollabTitlebarItem {
.with_style(theme.titlebar.offline_icon.container) .with_style(theme.titlebar.offline_icon.container)
.into_any(), .into_any(),
), ),
client::Status::UpgradeRequired => Some( client::Status::UpgradeRequired => {
MouseEventHandler::new::<ConnectionStatusButton, _>(0, cx, |_, _| { let auto_updater = auto_update::AutoUpdater::get(cx);
Label::new( let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) {
"Please update Zed to collaborate", Some(AutoUpdateStatus::Updated) => "Please restart Zed to Collaborate",
theme.titlebar.outdated_warning.text.clone(), Some(AutoUpdateStatus::Installing)
) | Some(AutoUpdateStatus::Downloading)
.contained() | Some(AutoUpdateStatus::Checking) => "Updating...",
.with_style(theme.titlebar.outdated_warning.container) Some(AutoUpdateStatus::Idle) | Some(AutoUpdateStatus::Errored) | None => {
.aligned() "Please update Zed to Collaborate"
}) }
.with_cursor_style(CursorStyle::PointingHand) };
.on_click(MouseButton::Left, |_, _, cx| {
auto_update::check(&Default::default(), cx); Some(
}) MouseEventHandler::new::<ConnectionStatusButton, _>(0, cx, |_, _| {
.into_any(), Label::new(label, theme.titlebar.outdated_warning.text.clone())
), .contained()
.with_style(theme.titlebar.outdated_warning.container)
.aligned()
})
.with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, _, cx| {
if let Some(auto_updater) = auto_update::AutoUpdater::get(cx) {
if auto_updater.read(cx).status() == AutoUpdateStatus::Updated {
workspace::restart(&Default::default(), cx);
return;
}
}
auto_update::check(&Default::default(), cx);
})
.into_any(),
)
}
_ => None, _ => None,
} }
} }