Wire up livestream debug toggle

Marshall Bowers created

Change summary

crates/ui2/src/components/title_bar.rs | 15 ++++---------
crates/ui2/src/components/workspace.rs | 31 +++++++++++++--------------
2 files changed, 20 insertions(+), 26 deletions(-)

Detailed changes

crates/ui2/src/components/title_bar.rs 🔗

@@ -6,7 +6,7 @@ use gpui3::{view, Context, View};
 use crate::prelude::*;
 use crate::settings::user_settings;
 use crate::{
-    random_players_with_call_status, theme, Avatar, Button, Icon, IconButton, IconColor, MicStatus,
+    theme, Avatar, Button, Icon, IconButton, IconColor, MicStatus, PlayerStack,
     PlayerWithCallStatus, ScreenShareStatus, ToolDivider, TrafficLights,
 };
 
@@ -80,14 +80,9 @@ impl TitleBar {
         cx.notify();
     }
 
-    pub fn view(cx: &mut WindowContext) -> View<Self> {
+    pub fn view(cx: &mut WindowContext, livestream: Option<Livestream>) -> View<Self> {
         view(
-            cx.entity(|cx| {
-                Self::new(cx).set_livestream(Some(Livestream {
-                    players: random_players_with_call_status(7),
-                    channel: Some("gpui2-ui".to_string()),
-                }))
-            }),
+            cx.entity(|cx| Self::new(cx).set_livestream(livestream)),
             Self::render,
         )
     }
@@ -133,7 +128,7 @@ impl TitleBar {
                             .child(Button::new("zed"))
                             .child(Button::new("nate/gpui2-ui-components")),
                     )
-                    // .children(player_list.map(|p| PlayerStack::new(p)))
+                    .children(player_list.map(|p| PlayerStack::new(p)))
                     .child(IconButton::new(Icon::Plus)),
             )
             .child(
@@ -204,7 +199,7 @@ mod stories {
         pub fn view(cx: &mut WindowContext) -> View<Self> {
             view(
                 cx.entity(|cx| Self {
-                    title_bar: TitleBar::view(cx),
+                    title_bar: TitleBar::view(cx, None),
                 }),
                 Self::render,
             )

crates/ui2/src/components/workspace.rs 🔗

@@ -3,12 +3,12 @@ use std::sync::Arc;
 use chrono::DateTime;
 use gpui3::{px, relative, rems, view, Context, Size, View};
 
-use crate::settings::FakeSettings;
-use crate::{prelude::*, user_settings_mut, Button, SettingValue};
+use crate::prelude::*;
 use crate::{
-    theme, v_stack, AssistantPanel, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label,
-    LanguageSelector, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel,
-    SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin,
+    static_livestream, theme, user_settings_mut, v_stack, AssistantPanel, Button, ChatMessage,
+    ChatPanel, CollabPanel, EditorPane, FakeSettings, Label, LanguageSelector, Livestream, Pane,
+    PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel, SettingValue, SplitDirection,
+    StatusBar, Terminal, TitleBar, Toast, ToastOrigin,
 };
 
 #[derive(Clone)]
@@ -50,7 +50,7 @@ pub struct Workspace {
 impl Workspace {
     pub fn new(cx: &mut ViewContext<Self>) -> Self {
         Self {
-            title_bar: TitleBar::view(cx),
+            title_bar: TitleBar::view(cx, None),
             editor_1: EditorPane::view(cx),
             show_project_panel: true,
             show_collab_panel: false,
@@ -159,20 +159,19 @@ impl Workspace {
     }
 
     pub fn debug_toggle_livestream(&mut self, cx: &mut ViewContext<Self>) {
-        if self.debug.in_livestream {
-            self.debug.in_livestream = false;
-        } else {
-            self.debug.in_livestream = true;
-        }
+        self.debug.in_livestream = !self.debug.in_livestream;
+
+        self.title_bar = TitleBar::view(
+            cx,
+            Some(static_livestream()).filter(|_| self.debug.in_livestream),
+        );
+
         cx.notify();
     }
 
     pub fn debug_toggle_toast(&mut self, cx: &mut ViewContext<Self>) {
-        if self.debug.show_toast {
-            self.debug.show_toast = false;
-        } else {
-            self.debug.show_toast = true;
-        }
+        self.debug.show_toast = !self.debug.show_toast;
+
         cx.notify();
     }