Merge claude/gifted-lovelace-1crlx2 (click-to-watch) into the negotiation work
The development branch gained watching a streaming user's stream from the channel list (voelin-ui only); it merges without conflicts, and the tree passes fmt and strict clippy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
a7a78d6ddd
9 files changed
+87
-2
No files matched your search
@@ -388,6 +388,9 @@ pub(crate) struct App {
|
|||||||
pub share_error: String,
|
pub share_error: String,
|
||||||
/// The stream in the viewer.
|
/// The stream in the viewer.
|
||||||
pub watch: Option<Watch>,
|
pub watch: Option<Watch>,
|
||||||
|
/// A client whose stream was asked for before it was known (session,
|
||||||
|
/// client): watched when the lookup brings it.
|
||||||
|
pub pending_watch: Option<(i64, u16)>,
|
||||||
/// Stream volume in percent, kept between streams.
|
/// Stream volume in percent, kept between streams.
|
||||||
pub stream_volume: f32,
|
pub stream_volume: f32,
|
||||||
/// `VOELIN_DEMO_STREAM`: the viewer shows a local test stream.
|
/// `VOELIN_DEMO_STREAM`: the viewer shows a local test stream.
|
||||||
@@ -595,6 +598,7 @@ pub fn run(options: RunOptions) -> Result<()> {
|
|||||||
share_busy: false,
|
share_busy: false,
|
||||||
share_error: String::new(),
|
share_error: String::new(),
|
||||||
watch: None,
|
watch: None,
|
||||||
|
pending_watch: None,
|
||||||
stream_volume: 100.0,
|
stream_volume: 100.0,
|
||||||
demo: switches.demo_stream,
|
demo: switches.demo_stream,
|
||||||
demo_ui: switches.demo_ui,
|
demo_ui: switches.demo_ui,
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ pub(super) fn wire(ui: &MainWindow) {
|
|||||||
bridge.on_watch_stream(|id| {
|
bridge.on_watch_stream(|id| {
|
||||||
with_app(|app| app.watch_stream(id.to_string()));
|
with_app(|app| app.watch_stream(id.to_string()));
|
||||||
});
|
});
|
||||||
|
bridge.on_watch_client(|client| {
|
||||||
|
if let Ok(client) = u16::try_from(client) {
|
||||||
|
with_app(|app| app.watch_client(client));
|
||||||
|
}
|
||||||
|
});
|
||||||
bridge.on_show_viewer(|| {
|
bridge.on_show_viewer(|| {
|
||||||
with_app(|app| app.show_viewer(true));
|
with_app(|app| app.show_viewer(true));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ impl App {
|
|||||||
volume: playback.volume * 100.0,
|
volume: playback.volume * 100.0,
|
||||||
muted: playback.muted,
|
muted: playback.muted,
|
||||||
known: uid.is_some(),
|
known: uid.is_some(),
|
||||||
|
streaming: client.streaming == Some(true),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
@@ -91,6 +92,10 @@ impl App {
|
|||||||
self.open_member(-1);
|
self.open_member(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"watch" => {
|
||||||
|
self.open_member(-1);
|
||||||
|
self.watch_client(client_id);
|
||||||
|
}
|
||||||
"poke" => {
|
"poke" => {
|
||||||
self.command(|session| Command::Poke {
|
self.command(|session| Command::Poke {
|
||||||
session,
|
session,
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ impl App {
|
|||||||
name: info.nickname.into(),
|
name: info.nickname.into(),
|
||||||
volume: playback.volume * 100.0,
|
volume: playback.volume * 100.0,
|
||||||
muted: playback.muted,
|
muted: playback.muted,
|
||||||
|
streaming: info.streaming == Some(true),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -179,10 +179,19 @@ impl App {
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|s| view.state.own_client != Some(s.streamer.0))
|
.find(|s| view.state.own_client != Some(s.streamer.0))
|
||||||
.map(|s| s.id.clone());
|
.map(|s| s.id.clone());
|
||||||
|
// A client whose stream was asked for while it was looked up.
|
||||||
|
let pending = self
|
||||||
|
.pending_watch
|
||||||
|
.filter(|(s, _)| *s == session as i64)
|
||||||
|
.and_then(|(_, client)| streams.iter().find(|s| s.streamer.0 == client))
|
||||||
|
.map(|s| s.id.clone());
|
||||||
view.streams = streams;
|
view.streams = streams;
|
||||||
self.refresh_streams();
|
self.refresh_streams();
|
||||||
self.refresh_servers();
|
self.refresh_servers();
|
||||||
if autowatch && let Some(id) = first {
|
if let Some(id) = pending {
|
||||||
|
self.pending_watch = None;
|
||||||
|
self.watch_stream(id);
|
||||||
|
} else if autowatch && let Some(id) = first {
|
||||||
self.watch_stream(id);
|
self.watch_stream(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -763,6 +772,27 @@ impl App {
|
|||||||
self.refresh_tree();
|
self.refresh_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Watch the stream of `client` (a click on a streaming user in the
|
||||||
|
/// channel tree or the members): at once if it is known, else as soon as
|
||||||
|
/// the lookup brings it (it may have started in another channel or
|
||||||
|
/// before we joined).
|
||||||
|
pub(crate) fn watch_client(&mut self, client: u16) {
|
||||||
|
let Some(session) = self.current else { return };
|
||||||
|
let Some(view) = self.sessions.get(&session) else { return };
|
||||||
|
if view.state.own_client == Some(client) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if let Some(id) = view.streams.iter().find(|s| s.streamer.0 == client).map(|s| s.id.clone())
|
||||||
|
{
|
||||||
|
self.pending_watch = None;
|
||||||
|
self.watch_stream(id);
|
||||||
|
} else if view.presence.clients.get(&client).is_some_and(|c| c.streaming == Some(true)) {
|
||||||
|
let name = view.nickname(client);
|
||||||
|
self.pending_watch = Some((session, client));
|
||||||
|
self.set_status(format!("Looking up {name}'s stream…"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// `VOELIN_OPEN=watch`: watch the first stream of our channel.
|
/// `VOELIN_OPEN=watch`: watch the first stream of our channel.
|
||||||
pub(crate) fn watch_first_stream(&mut self) {
|
pub(crate) fn watch_first_stream(&mut self) {
|
||||||
let Some(id) = self.view().and_then(|v| {
|
let Some(id) = self.view().and_then(|v| {
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ export struct MemberCard {
|
|||||||
muted: bool,
|
muted: bool,
|
||||||
// The client has a unique id, so contacts and private chats work.
|
// The client has a unique id, so contacts and private chats work.
|
||||||
known: bool,
|
known: bool,
|
||||||
|
// The client streams: the card offers to watch it.
|
||||||
|
streaming: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
export struct ChatTab {
|
export struct ChatTab {
|
||||||
@@ -299,6 +301,8 @@ export struct ClientAudio {
|
|||||||
name: string,
|
name: string,
|
||||||
volume: float,
|
volume: float,
|
||||||
muted: bool,
|
muted: bool,
|
||||||
|
// The client streams: the dialog offers to watch it.
|
||||||
|
streaming: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The appearance settings (`ui.*` keys).
|
// The appearance settings (`ui.*` keys).
|
||||||
@@ -489,6 +493,9 @@ export global Bridge {
|
|||||||
callback respond-viewer(int, bool);
|
callback respond-viewer(int, bool);
|
||||||
callback kick-viewer(int);
|
callback kick-viewer(int);
|
||||||
callback watch-stream(string);
|
callback watch-stream(string);
|
||||||
|
// Watch the stream of a client (a streaming user in the tree or the
|
||||||
|
// members), as soon as it is known.
|
||||||
|
callback watch-client(int);
|
||||||
callback show-viewer();
|
callback show-viewer();
|
||||||
callback hide-viewer();
|
callback hide-viewer();
|
||||||
callback leave-stream();
|
callback leave-stream();
|
||||||
|
|||||||
@@ -226,9 +226,26 @@ component TreeRow inherits Rectangle {
|
|||||||
alignment: center;
|
alignment: center;
|
||||||
SpeakingBars { }
|
SpeakingBars { }
|
||||||
}
|
}
|
||||||
|
// A click on someone's LIVE mark watches their stream.
|
||||||
if item.streaming: VerticalLayout {
|
if item.streaming: VerticalLayout {
|
||||||
alignment: center;
|
alignment: center;
|
||||||
LiveBadge { }
|
LiveBadge {
|
||||||
|
accessible-role: AccessibleRole.button;
|
||||||
|
accessible-label: item.myself ? @tr("Your stream") : @tr("Watch {}'s stream", item.name);
|
||||||
|
accessible-action-default => {
|
||||||
|
if !item.myself {
|
||||||
|
Bridge.watch-client(item.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TouchArea {
|
||||||
|
mouse-cursor: item.myself ? MouseCursor.default : MouseCursor.pointer;
|
||||||
|
clicked => {
|
||||||
|
if !item.myself {
|
||||||
|
Bridge.watch-client(item.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if item.local-muted: Icon {
|
if item.local-muted: Icon {
|
||||||
source: Icons.volume-x;
|
source: Icons.volume-x;
|
||||||
|
|||||||
@@ -499,6 +499,15 @@ export component ClientAudioDialog inherits Modal {
|
|||||||
Bridge.client-audio-changed(Bridge.client-audio);
|
Bridge.client-audio-changed(Bridge.client-audio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if Bridge.client-audio.streaming: Button {
|
||||||
|
kind: ButtonKind.primary;
|
||||||
|
icon: Icons.monitor;
|
||||||
|
text: @tr("Watch {}'s stream", Bridge.client-audio.name);
|
||||||
|
clicked => {
|
||||||
|
Bridge.watch-client(Bridge.client-audio.id);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
}
|
||||||
Rectangle { vertical-stretch: 1; }
|
Rectangle { vertical-stretch: 1; }
|
||||||
Footer {
|
Footer {
|
||||||
Button {
|
Button {
|
||||||
|
|||||||
@@ -308,6 +308,13 @@ export component MemberCardPopup inherits Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Divider { }
|
Divider { }
|
||||||
|
if Bridge.member-card.streaming: Button {
|
||||||
|
small: true;
|
||||||
|
kind: ButtonKind.primary;
|
||||||
|
icon: Icons.monitor;
|
||||||
|
text: @tr("Watch stream");
|
||||||
|
clicked => { Bridge.member-action("watch"); }
|
||||||
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
spacing: Theme.space-2;
|
spacing: Theme.space-2;
|
||||||
Button {
|
Button {
|
||||||
|
|||||||
Reference in new issue
Block a user