Revert "Remove ChannelsAlpha flag"

This reverts commit 1c1151a0ed.
This commit is contained in:
Conrad Irwin 2024-01-10 11:52:33 -07:00
parent 8d1bca450f
commit 61a9a3a274
4 changed files with 118 additions and 98 deletions

View File

@ -1,4 +1,4 @@
use crate::{channel_view::ChannelView, ChatPanelSettings};
use crate::{channel_view::ChannelView, is_channels_feature_enabled, ChatPanelSettings};
use anyhow::Result;
use call::ActiveCall;
use channel::{ChannelChat, ChannelChatEvent, ChannelMessageId, ChannelStore};
@ -612,6 +612,9 @@ impl Panel for ChatPanel {
self.active = active;
if active {
self.acknowledge_last_message(cx);
if !is_channels_feature_enabled(cx) {
cx.emit(Event::Dismissed);
}
}
}
@ -620,6 +623,10 @@ impl Panel for ChatPanel {
}
fn icon(&self, cx: &WindowContext) -> Option<ui::IconName> {
if !is_channels_feature_enabled(cx) {
return None;
}
Some(ui::IconName::MessageBubbles).filter(|_| ChatPanelSettings::get_global(cx).button)
}

View File

@ -12,6 +12,7 @@ use client::{Client, Contact, User, UserStore};
use contact_finder::ContactFinder;
use db::kvp::KEY_VALUE_STORE;
use editor::{Editor, EditorElement, EditorStyle};
use feature_flags::{ChannelsAlpha, FeatureFlagAppExt, FeatureFlagViewExt};
use fuzzy::{match_strings, StringMatchCandidate};
use gpui::{
actions, canvas, div, fill, list, overlay, point, prelude::*, px, AnyElement, AppContext,
@ -277,6 +278,10 @@ impl CollabPanel {
}));
this.subscriptions
.push(cx.observe(&active_call, |this, _, cx| this.update_entries(true, cx)));
this.subscriptions
.push(cx.observe_flag::<ChannelsAlpha, _>(move |_, this, cx| {
this.update_entries(true, cx)
}));
this.subscriptions.push(cx.subscribe(
&this.channel_store,
|this, _channel_store, e, cx| match e {
@ -512,21 +517,19 @@ impl CollabPanel {
let mut request_entries = Vec::new();
if cx.has_flag::<ChannelsAlpha>() {
self.entries.push(ListEntry::Header(Section::Channels));
if channel_store.channel_count() > 0 || self.channel_editing_state.is_some() {
self.match_candidates.clear();
self.match_candidates
.extend(
channel_store
.ordered_channels()
.enumerate()
.map(|(ix, (_, channel))| StringMatchCandidate {
.extend(channel_store.ordered_channels().enumerate().map(
|(ix, (_, channel))| StringMatchCandidate {
id: ix,
string: channel.name.clone().into(),
char_bag: channel.name.chars().collect(),
}),
);
},
));
let matches = executor.block(match_strings(
&self.match_candidates,
&query,
@ -613,11 +616,9 @@ impl CollabPanel {
&Default::default(),
executor.clone(),
));
request_entries.extend(
matches
.iter()
.map(|mat| ListEntry::ChannelInvite(channel_invites[mat.candidate_id].clone())),
);
request_entries.extend(matches.iter().map(|mat| {
ListEntry::ChannelInvite(channel_invites[mat.candidate_id].clone())
}));
if !request_entries.is_empty() {
self.entries
@ -627,6 +628,7 @@ impl CollabPanel {
}
}
}
}
self.entries.push(ListEntry::Header(Section::Contacts));

View File

@ -12,6 +12,7 @@ use std::{rc::Rc, sync::Arc};
use call::{report_call_event_for_room, ActiveCall, Room};
pub use collab_panel::CollabPanel;
pub use collab_titlebar_item::CollabTitlebarItem;
use feature_flags::{ChannelsAlpha, FeatureFlagAppExt};
use gpui::{
actions, point, AppContext, GlobalPixels, Pixels, PlatformDisplay, Size, Task, WindowBounds,
WindowKind, WindowOptions,
@ -158,3 +159,7 @@ fn notification_window_options(
// .with_style(container)
// .into_any()
// }
fn is_channels_feature_enabled(cx: &gpui::WindowContext<'_>) -> bool {
cx.is_staff() || cx.has_flag::<ChannelsAlpha>()
}

View File

@ -16,6 +16,12 @@ pub trait FeatureFlag {
const NAME: &'static str;
}
pub enum ChannelsAlpha {}
impl FeatureFlag for ChannelsAlpha {
const NAME: &'static str = "channels_alpha";
}
pub trait FeatureFlagViewExt<V: 'static> {
fn observe_flag<T: FeatureFlag, F>(&mut self, callback: F) -> Subscription
where