@@ -123,7 +123,7 @@ impl ChannelStore {
pub fn get_channel_members(
&self,
channel_id: ChannelId,
- ) -> impl Future<Output = Result<HashMap<UserId, ChannelMemberStatus>>> {
+ ) -> impl 'static + Future<Output = Result<HashMap<UserId, ChannelMemberStatus>>> {
let client = self.client.clone();
async move {
let response = client
@@ -1678,20 +1678,28 @@ impl CollabPanel {
}
fn add_member(&mut self, action: &AddMember, cx: &mut ViewContext<Self>) {
- if let Some(workspace) = self.workspace.upgrade(cx) {
- workspace.update(cx, |workspace, cx| {
+ let channel_id = action.channel_id;
+ let workspace = self.workspace.clone();
+ let user_store = self.user_store.clone();
+ let channel_store = self.channel_store.clone();
+ let members = self.channel_store.read(cx).get_channel_members(channel_id);
+ cx.spawn(|_, mut cx| async move {
+ let members = members.await?;
+ workspace.update(&mut cx, |workspace, cx| {
workspace.toggle_modal(cx, |_, cx| {
cx.add_view(|cx| {
build_channel_modal(
- self.user_store.clone(),
- self.channel_store.clone(),
- action.channel_id,
+ user_store.clone(),
+ channel_store.clone(),
+ channel_id,
+ members,
cx,
)
})
- })
- });
- }
+ });
+ })
+ })
+ .detach();
}
fn remove_channel(&mut self, action: &RemoveChannel, cx: &mut ViewContext<Self>) {
@@ -17,6 +17,7 @@ pub fn build_channel_modal(
user_store: ModelHandle<UserStore>,
channel_store: ModelHandle<ChannelStore>,
channel: ChannelId,
+ members: HashMap<UserId, ChannelMemberStatus>,
cx: &mut ViewContext<ChannelModal>,
) -> ChannelModal {
Picker::new(
@@ -26,7 +27,7 @@ pub fn build_channel_modal(
user_store,
channel_store,
channel_id: channel,
- member_statuses: Default::default(),
+ member_statuses: members,
},
cx,
)