Merge the development branch: streams of every channel

Brings in the streams of every channel (StreamItem::channel, the streams
panel listing other channels' streams after ours, the viewer's channel)
and the answer to a streamer's new offer.

streams.rs keeps both of the viewer's new values: whether the streamer
is an admin (this branch) and the stream's channel (the development
branch). The phone's pieces that list Bridge.streams now say where a
stream of another channel is: the voice screen's stream cards ("Lumen ·
in Gaming") and Home's Live now cards, whose comment and the server
rail's live flag no longer claim they are about our channel only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 22:24:13 +03:00
commit acbb8c1124
18 files changed
+342 -71

No files matched your search

+13
View File
@@ -248,6 +248,19 @@ impl SessionView {
self.capabilities.streams && self.state.voice == VoiceState::Connected
}
/// The channel a client is in.
pub fn channel_of(&self, client: u16) -> Option<u64> {
self.presence.clients.get(&client).map(|c| c.channel)
}
/// The name of a client's channel when it is not ours; empty in ours.
pub fn other_channel_name(&self, client: u16) -> String {
self.channel_of(client)
.filter(|c| Some(*c) != self.state.own_channel)
.and_then(|c| self.presence.channels.get(&c))
.map_or_else(String::new, |c| c.name.clone())
}
/// A client's nickname, or its id.
pub fn nickname(&self, client: u16) -> String {
self.presence
+18 -10
View File
@@ -215,7 +215,12 @@ impl App {
let current = self.current;
let mut items: Vec<StreamItem> = Vec::new();
if let Some(view) = view.filter(|v| v.streams_available()) {
for s in &view.streams {
// Every channel's streams (they can be watched from anywhere),
// ours first.
let own_channel = view.state.own_channel;
let mut streams: Vec<_> = view.streams.iter().collect();
streams.sort_by_key(|s| view.channel_of(s.streamer.0) != own_channel);
for s in streams {
let watching = self
.watch
.as_ref()
@@ -224,6 +229,7 @@ impl App {
id: s.id.clone().into(),
name: s.name.clone().into(),
streamer: view.nickname(s.streamer.0).into(),
channel: view.other_channel_name(s.streamer.0).into(),
streamer_id: i32::from(s.streamer.0),
viewers: view.stream_viewers.get(&s.id).map_or(0, |v| *v as i32),
audio: s.audio,
@@ -239,20 +245,17 @@ impl App {
bitrate: bitrate_text(s.bitrate).into(),
});
}
// Streams that started before we joined: the server did not
// announce them, and the engine is looking them up (they arrive
// in `StreamsChanged` like the others). Until then only the
// streaming flag is known.
let channel = view.state.own_channel;
// Streams that started before we joined, or in another channel:
// the server did not announce them, and the engine is looking
// them up (they arrive in `StreamsChanged` like the others).
// Until then only the streaming flag is known.
for c in view.presence.clients.values() {
let announced = view.streams.iter().any(|s| s.streamer.0 == c.id);
if c.streaming == Some(true)
&& Some(c.channel) == channel
&& !announced && view.state.own_client != Some(c.id)
{
if c.streaming == Some(true) && !announced && view.state.own_client != Some(c.id) {
items.push(StreamItem {
name: c.nickname.clone().into(),
streamer: c.nickname.clone().into(),
channel: view.other_channel_name(c.id).into(),
streamer_id: i32::from(c.id),
..StreamItem::default()
});
@@ -352,6 +355,11 @@ impl App {
.filter_map(|i| members.row_data(i))
.any(|m| m.id == streamer && m.admin),
);
let channel = u16::try_from(streamer).ok().and_then(|id| {
let view = self.view()?;
view.presence.channels.get(&view.channel_of(id)?).map(|c| c.name.clone())
});
bridge.set_viewer_channel(channel.unwrap_or_default().into());
bridge.set_viewer_elapsed(watch.elapsed().into());
let viewers = self.view().and_then(|v| v.stream_viewers.get(&watch.stream_id)).copied();
bridge.set_viewer_count(viewers.unwrap_or(0) as i32);
+1 -1
View File
@@ -17,7 +17,7 @@ pub fn status(state: &SessionState) -> &'static str {
}
/// A server of the rail. `unread`: messages in its chats; `live`:
/// streams in our channel there.
/// streams on it.
pub fn item(bookmark: &Bookmark, state: &SessionState, unread: i32, live: bool) -> ServerItem {
ServerItem {
id: bookmark.id as i32,