channel projects (#8456)

Add plumbing for hosted projects. This will currently show them if they
exist
but provides no UX to create/rename/delete them.

Also changed the `ChannelId` type to not auto-cast to u64; this avoids
type
confusion if you have multiple id types.


Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-02-26 22:15:11 -07:00 committed by GitHub
parent 8cf36ae603
commit c31626717f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 446 additions and 144 deletions

View file

@ -5,7 +5,7 @@ pub mod room;
use anyhow::{anyhow, Result};
use audio::Audio;
use call_settings::CallSettings;
use client::{proto, Client, TypedEnvelope, User, UserStore, ZED_ALWAYS_ACTIVE};
use client::{proto, ChannelId, Client, TypedEnvelope, User, UserStore, ZED_ALWAYS_ACTIVE};
use collections::HashSet;
use futures::{channel::oneshot, future::Shared, Future, FutureExt};
use gpui::{
@ -107,7 +107,7 @@ impl ActiveCall {
}
}
pub fn channel_id(&self, cx: &AppContext) -> Option<u64> {
pub fn channel_id(&self, cx: &AppContext) -> Option<ChannelId> {
self.room()?.read(cx).channel_id()
}
@ -336,7 +336,7 @@ impl ActiveCall {
pub fn join_channel(
&mut self,
channel_id: u64,
channel_id: ChannelId,
cx: &mut ModelContext<Self>,
) -> Task<Result<Option<Model<Room>>>> {
if let Some(room) = self.room().cloned() {
@ -487,7 +487,7 @@ impl ActiveCall {
pub fn report_call_event_for_room(
operation: &'static str,
room_id: u64,
channel_id: Option<u64>,
channel_id: Option<ChannelId>,
client: &Arc<Client>,
) {
let telemetry = client.telemetry();
@ -497,7 +497,7 @@ pub fn report_call_event_for_room(
pub fn report_call_event_for_channel(
operation: &'static str,
channel_id: u64,
channel_id: ChannelId,
client: &Arc<Client>,
cx: &AppContext,
) {

View file

@ -6,7 +6,7 @@ use anyhow::{anyhow, Result};
use audio::{Audio, Sound};
use client::{
proto::{self, PeerId},
Client, ParticipantIndex, TypedEnvelope, User, UserStore,
ChannelId, Client, ParticipantIndex, TypedEnvelope, User, UserStore,
};
use collections::{BTreeMap, HashMap, HashSet};
use fs::Fs;
@ -27,7 +27,7 @@ pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Event {
RoomJoined {
channel_id: Option<u64>,
channel_id: Option<ChannelId>,
},
ParticipantLocationChanged {
participant_id: proto::PeerId,
@ -53,13 +53,13 @@ pub enum Event {
project_id: u64,
},
Left {
channel_id: Option<u64>,
channel_id: Option<ChannelId>,
},
}
pub struct Room {
id: u64,
channel_id: Option<u64>,
channel_id: Option<ChannelId>,
live_kit: Option<LiveKitRoom>,
status: RoomStatus,
shared_projects: HashSet<WeakModel<Project>>,
@ -84,7 +84,7 @@ pub struct Room {
impl EventEmitter<Event> for Room {}
impl Room {
pub fn channel_id(&self) -> Option<u64> {
pub fn channel_id(&self) -> Option<ChannelId> {
self.channel_id
}
@ -106,7 +106,7 @@ impl Room {
fn new(
id: u64,
channel_id: Option<u64>,
channel_id: Option<ChannelId>,
live_kit_connection_info: Option<proto::LiveKitConnectionInfo>,
client: Arc<Client>,
user_store: Model<UserStore>,
@ -273,13 +273,17 @@ impl Room {
}
pub(crate) async fn join_channel(
channel_id: u64,
channel_id: ChannelId,
client: Arc<Client>,
user_store: Model<UserStore>,
cx: AsyncAppContext,
) -> Result<Model<Self>> {
Self::from_join_response(
client.request(proto::JoinChannel { channel_id }).await?,
client
.request(proto::JoinChannel {
channel_id: channel_id.0,
})
.await?,
client,
user_store,
cx,
@ -337,7 +341,7 @@ impl Room {
let room = cx.new_model(|cx| {
Self::new(
room_proto.id,
response.channel_id,
response.channel_id.map(ChannelId),
response.live_kit_connection_info,
client,
user_store,