From 9590f253a924334cd451db30516ff72a9ea209ff Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:46:07 +0100 Subject: [PATCH] Fix warnings --- crates/call2/src/call2.rs | 9 ++---- crates/call2/src/room.rs | 9 ++---- crates/call2/src/shared_screen.rs | 20 ++++--------- crates/collab_ui2/src/collab_panel.rs | 14 ++++++--- crates/collab_ui2/src/collab_titlebar_item.rs | 27 ++++++++++------- crates/collab_ui2/src/collab_ui.rs | 8 ++--- .../incoming_call_notification.rs | 29 +++++++++---------- 7 files changed, 56 insertions(+), 60 deletions(-) diff --git a/crates/call2/src/call2.rs b/crates/call2/src/call2.rs index 5933f7404f42d9dcab96261cea0cbdd5070ab073..f9a7e4bcfa845edfa8a38e3fc2b92d473ed1399e 100644 --- a/crates/call2/src/call2.rs +++ b/crates/call2/src/call2.rs @@ -18,7 +18,6 @@ use gpui::{ Subscription, Task, View, ViewContext, VisualContext, WeakModel, WeakView, }; pub use participant::ParticipantLocation; -use participant::RemoteParticipant; use postage::watch; use project::Project; use room::Event; @@ -666,7 +665,7 @@ impl CallHandler for Call { call.0.update(cx, |this, cx| { this.room().map(|room| { room.update(cx, |this, cx| { - this.toggle_mute(cx); + this.toggle_mute(cx).log_err(); }) }) }) @@ -678,12 +677,10 @@ impl CallHandler for Call { this.room().map(|room| { room.update(cx, |this, cx| { if this.is_screen_sharing() { - dbg!("Unsharing"); - this.unshare_screen(cx); + this.unshare_screen(cx).log_err(); } else { - dbg!("Sharing"); let t = this.share_screen(cx); - cx.spawn(move |_, cx| async move { + cx.spawn(move |_, _| async move { t.await.log_err(); }) .detach(); diff --git a/crates/call2/src/room.rs b/crates/call2/src/room.rs index 5bba4cc75063532125d6cd12fa97187241142138..1f299ff6cb9342bd6d390ec5717379961db95052 100644 --- a/crates/call2/src/room.rs +++ b/crates/call2/src/room.rs @@ -1,7 +1,4 @@ -use crate::{ - call_settings::CallSettings, - participant::{LocalParticipant, ParticipantLocation, RemoteParticipant}, -}; +use crate::participant::{LocalParticipant, ParticipantLocation, RemoteParticipant}; use anyhow::{anyhow, Result}; use audio::{Audio, Sound}; use client::{ @@ -21,7 +18,6 @@ use live_kit_client::{ }; use postage::{sink::Sink, stream::Stream, watch}; use project::Project; -use settings::Settings; use std::{future::Future, mem, sync::Arc, time::Duration}; use util::{post_inc, ResultExt, TryFutureExt}; @@ -332,7 +328,8 @@ impl Room { } } - pub fn mute_on_join(cx: &AppContext) -> bool { + pub fn mute_on_join(_cx: &AppContext) -> bool { + // todo!() po: This should be uncommented, though then unmuting does not work false //CallSettings::get_global(cx).mute_on_join || client::IMPERSONATE_LOGIN.is_some() } diff --git a/crates/call2/src/shared_screen.rs b/crates/call2/src/shared_screen.rs index a281948d6f10d682090d5c8d71c309d403424d01..6f0024b63da13894b4130c077ef94f66481cec7e 100644 --- a/crates/call2/src/shared_screen.rs +++ b/crates/call2/src/shared_screen.rs @@ -3,19 +3,11 @@ use anyhow::Result; use client::{proto::PeerId, User}; use futures::StreamExt; use gpui::{ - div, img, AppContext, Div, Element, Entity, EventEmitter, FocusHandle, FocusableView, - ImageData, Img, MouseButton, ParentElement, Render, SharedString, Task, View, ViewContext, - VisualContext, WindowContext, -}; -use smallvec::SmallVec; -use std::{ - borrow::Cow, - sync::{Arc, Weak}, -}; -use workspace::{ - item::{Item, ItemEvent}, - ItemNavHistory, WorkspaceId, + div, img, AppContext, Div, Element, EventEmitter, FocusHandle, FocusableView, ImageData, + ParentElement, Render, SharedString, Task, View, ViewContext, VisualContext, WindowContext, }; +use std::sync::{Arc, Weak}; +use workspace::{item::Item, ItemNavHistory, WorkspaceId}; pub enum Event { Close, @@ -65,13 +57,13 @@ impl EventEmitter for SharedScreen {} impl EventEmitter for SharedScreen {} impl FocusableView for SharedScreen { - fn focus_handle(&self, cx: &AppContext) -> FocusHandle { + fn focus_handle(&self, _: &AppContext) -> FocusHandle { self.focus.clone() } } impl Render for SharedScreen { type Element = Div; - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { + fn render(&mut self, _: &mut ViewContext) -> Self::Element { let frame = self.frame.clone(); div().children(frame.map(|frame| { img().data(Arc::new(ImageData::new(image::ImageBuffer::new( diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rs index 22a8a2cbba6b18806f3e612c7dd29e7677dcd536..e9c17a6589dd79c73edc9b6e29bea4c76740b20e 100644 --- a/crates/collab_ui2/src/collab_panel.rs +++ b/crates/collab_ui2/src/collab_panel.rs @@ -302,7 +302,7 @@ pub struct CollabPanel { // entries: Vec, // selection: Option, user_store: Model, - client: Arc, + _client: Arc, // channel_store: ModelHandle, // project: ModelHandle, // match_candidates: Vec, @@ -605,7 +605,7 @@ impl CollabPanel { // collapsed_sections: vec![Section::Offline], // collapsed_channels: Vec::default(), _workspace: workspace.weak_handle(), - client: workspace.app_state().client.clone(), + _client: workspace.app_state().client.clone(), // context_menu_on_selected: true, // drag_target_channel: ChannelDragTarget::None, // list_state, @@ -3323,8 +3323,14 @@ impl Render for CollabPanel { .child(Label::new(contact.user.github_login.clone())) .on_mouse_down(gpui::MouseButton::Left, { let workspace = workspace.clone(); - move |event, cx| { - workspace.update(cx, |this, cx| this.call_state().invite(id, None, cx)); + move |_, cx| { + workspace + .update(cx, |this, cx| { + this.call_state() + .invite(id, None, cx) + .detach_and_log_err(cx) + }) + .log_err(); } }) })) diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rs index 9386d3ff35e540ab209cc44c8331bc1414871aa3..25a4db8c90ff235e1aaf3197809363fcee14906d 100644 --- a/crates/collab_ui2/src/collab_titlebar_item.rs +++ b/crates/collab_ui2/src/collab_titlebar_item.rs @@ -37,7 +37,7 @@ use gpui::{ }; use project::Project; use theme::ActiveTheme; -use ui::{h_stack, Avatar, Button, ButtonVariant, Color, IconButton, KeyBinding, Label, Tooltip}; +use ui::{h_stack, Avatar, Button, ButtonVariant, Color, IconButton, KeyBinding, Tooltip}; use util::ResultExt; use workspace::Workspace; @@ -190,11 +190,12 @@ impl Render for CollabTitlebarItem { .child(Avatar::data(avatar.clone()).into_element()) .on_mouse_down(MouseButton::Left, { let workspace = workspace.clone(); - let id = peer_id.clone(); move |_, cx| { - workspace.update(cx, |this, cx| { - this.open_shared_screen(peer_id, cx); - }); + workspace + .update(cx, |this, cx| { + this.open_shared_screen(peer_id, cx); + }) + .log_err(); } }) }) @@ -215,17 +216,21 @@ impl Render for CollabTitlebarItem { .child(IconButton::new("mute-microphone", mic_icon).on_click({ let workspace = workspace.clone(); move |_, cx| { - workspace.update(cx, |this, cx| { - this.call_state().toggle_mute(cx); - }); + workspace + .update(cx, |this, cx| { + this.call_state().toggle_mute(cx); + }) + .log_err(); } })) .child(IconButton::new("mute-sound", ui::Icon::AudioOn)) .child(IconButton::new("screen-share", ui::Icon::Screen).on_click( move |_, cx| { - workspace.update(cx, |this, cx| { - this.call_state().toggle_screen_share(cx); - }); + workspace + .update(cx, |this, cx| { + this.call_state().toggle_screen_share(cx); + }) + .log_err(); }, )) .pl_2(), diff --git a/crates/collab_ui2/src/collab_ui.rs b/crates/collab_ui2/src/collab_ui.rs index d1e4bea7d62464d7bc10517ac60f632fa80b8a06..679a6a135b13832936b381bbff71015eb6636682 100644 --- a/crates/collab_ui2/src/collab_ui.rs +++ b/crates/collab_ui2/src/collab_ui.rs @@ -12,8 +12,8 @@ use std::{rc::Rc, sync::Arc}; pub use collab_panel::CollabPanel; pub use collab_titlebar_item::CollabTitlebarItem; use gpui::{ - point, px, AppContext, GlobalPixels, Pixels, PlatformDisplay, Point, Size, WindowBounds, - WindowKind, WindowOptions, + AppContext, GlobalPixels, Pixels, PlatformDisplay, Size, WindowBounds, WindowKind, + WindowOptions, }; pub use panel_settings::{ ChatPanelSettings, CollaborationPanelSettings, NotificationPanelSettings, @@ -102,10 +102,10 @@ fn notification_window_options( screen: Rc, window_size: Size, ) -> WindowOptions { - let notification_padding = Pixels::from(16.); + let _notification_padding = Pixels::from(16.); let screen_bounds = screen.bounds(); - let size: Size = window_size.into(); + let _size: Size = window_size.into(); let bounds = gpui::Bounds:: { origin: screen_bounds.origin, diff --git a/crates/collab_ui2/src/notifications/incoming_call_notification.rs b/crates/collab_ui2/src/notifications/incoming_call_notification.rs index f47fcf07515195d325a663621fa9d34a55571452..b139afcc2f4ed91857b412bd29a123f3381fb536 100644 --- a/crates/collab_ui2/src/notifications/incoming_call_notification.rs +++ b/crates/collab_ui2/src/notifications/incoming_call_notification.rs @@ -1,11 +1,9 @@ use crate::notification_window_options; use call::{ActiveCall, IncomingCall}; -use client::proto; use futures::StreamExt; use gpui::{ - blue, div, green, px, red, AnyElement, AppContext, Component, Context, Div, Element, Entity, - EventEmitter, GlobalPixels, ParentElement, Render, RenderOnce, StatefulInteractiveElement, - Styled, View, ViewContext, VisualContext as _, WindowHandle, + div, green, px, red, AppContext, Div, Element, ParentElement, Render, RenderOnce, + StatefulInteractiveElement, Styled, ViewContext, VisualContext as _, WindowHandle, }; use std::sync::{Arc, Weak}; use ui::{h_stack, v_stack, Avatar, Button, Label}; @@ -19,11 +17,12 @@ pub fn init(app_state: &Arc, cx: &mut AppContext) { let mut notification_windows: Vec> = Vec::new(); while let Some(incoming_call) = incoming_call.next().await { for window in notification_windows.drain(..) { - window.update(&mut cx, |this, cx| { - //cx.remove_window(); - }); - //cx.update_window(window.into(), |this, cx| cx.remove_window()); - //window.remove(&mut cx); + window + .update(&mut cx, |_, _| { + // todo!() + //cx.remove_window(); + }) + .log_err(); } if let Some(incoming_call) = incoming_call { @@ -85,15 +84,14 @@ impl IncomingCallNotificationState { let active_call = ActiveCall::global(cx); if accept { let join = active_call.update(cx, |active_call, cx| active_call.accept_incoming(cx)); - let caller_user_id = self.call.calling_user.id; let initial_project_id = self.call.initial_project.as_ref().map(|project| project.id); let app_state = self.app_state.clone(); let cx: &mut AppContext = cx; - cx.spawn(|mut cx| async move { + cx.spawn(|cx| async move { join.await?; - if let Some(project_id) = initial_project_id { - cx.update(|cx| { - if let Some(app_state) = app_state.upgrade() { + if let Some(_project_id) = initial_project_id { + cx.update(|_cx| { + if let Some(_app_state) = app_state.upgrade() { // workspace::join_remote_project( // project_id, // caller_user_id, @@ -102,7 +100,8 @@ impl IncomingCallNotificationState { // ) // .detach_and_log_err(cx); } - }); + }) + .log_err(); } anyhow::Ok(()) })