feat(sidebar): channel list like Teams
- 32 px channel rows without #, names aligned with the team name - last activity on the right: time today, day/month this year, full date before - lock after private channel names, 20 px square team icon - "See all channels" link instead of "N hidden channels" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -8,8 +8,9 @@ macro_rules! symbols {
8
8
};
9
9
}
10
10
11
const SYMBOLS: [(&str, &[u8]); 78] = symbols![
11
const SYMBOLS: [(&str, &[u8]); 79] = symbols![
12
12
"campaign",
13
"lock",
13
14
"bot",
14
15
"copilot_color",
15
16
"done",
@@ -8,8 +8,9 @@ macro_rules! symbols {8
};8
};9
}9
}10
10
11
const SYMBOLS: [(&str, &[u8]); 78] = symbols![11
const SYMBOLS: [(&str, &[u8]); 79] = symbols![12
"campaign",12
"campaign",13
"lock",13
"bot",14
"bot",14
"copilot_color",15
"copilot_color",15
"done",16
"done",@@ -142,6 +142,28 @@ pub fn list_time_label_in(
142
142
}
143
143
}
144
144
145
/// The last activity next to a channel name: the time today, else day and month, with the year once older.
146
pub fn channel_time_label(time: DateTime<Utc>, today: NaiveDate, offset: FixedOffset) -> String {
147
channel_time_label_in(current_date_style(), time, today, offset)
148
}
149
150
pub fn channel_time_label_in(
151
style: Option<DateStyle>,
152
time: DateTime<Utc>,
153
today: NaiveDate,
154
offset: FixedOffset,
155
) -> String {
156
let local = time.with_timezone(&offset);
157
let pattern = if local.date_naive() >= today {
158
style.map_or("%H:%M", |style| style.clock)
159
} else if local.year() == today.year() {
160
style.map_or("%b %-d", |style| style.day_month)
161
} else {
162
style.map_or("%b %-d, %Y", |style| style.day_month_year)
163
};
164
local.format(pattern).to_string()
165
}
166
145
167
pub fn post_time_label(time: DateTime<Utc>, today: NaiveDate, offset: FixedOffset) -> String {
146
168
post_time_label_in(current_date_style(), time, today, offset)
147
169
}
@@ -209,6 +231,18 @@ mod tests {
209
231
FixedOffset::east_opt(0).unwrap()
210
232
}
211
233
234
#[test]
235
fn channel_times_show_the_clock_today_then_day_and_month_then_the_year() {
236
let style = Some(date_style("en-gb"));
237
let label = |time| channel_time_label_in(style, time, today(), zero());
238
assert_eq!(label(utc(7, 8)), "08:05");
239
assert_eq!(label(utc(1, 8)), "01/10");
240
assert_eq!(
241
label(Utc.with_ymd_and_hms(2025, 10, 23, 8, 0, 0).unwrap()),
242
"23/10/2025"
243
);
244
}
245
212
246
#[test]
213
247
fn palette_index_is_stable_and_in_range() {
214
248
assert_eq!(palette_index("user-1"), palette_index("user-1"));
@@ -142,6 +142,28 @@ pub fn list_time_label_in(142
}142
}143
}143
}144
144
145
/// The last activity next to a channel name: the time today, else day and month, with the year once older.146
pub fn channel_time_label(time: DateTime<Utc>, today: NaiveDate, offset: FixedOffset) -> String {147
channel_time_label_in(current_date_style(), time, today, offset)148
}149
150
pub fn channel_time_label_in(151
style: Option<DateStyle>,152
time: DateTime<Utc>,153
today: NaiveDate,154
offset: FixedOffset,155
) -> String {156
let local = time.with_timezone(&offset);157
let pattern = if local.date_naive() >= today {158
style.map_or("%H:%M", |style| style.clock)159
} else if local.year() == today.year() {160
style.map_or("%b %-d", |style| style.day_month)161
} else {162
style.map_or("%b %-d, %Y", |style| style.day_month_year)163
};164
local.format(pattern).to_string()165
}166
145
pub fn post_time_label(time: DateTime<Utc>, today: NaiveDate, offset: FixedOffset) -> String {167
pub fn post_time_label(time: DateTime<Utc>, today: NaiveDate, offset: FixedOffset) -> String {146
post_time_label_in(current_date_style(), time, today, offset)168
post_time_label_in(current_date_style(), time, today, offset)147
}169
}@@ -209,6 +231,18 @@ mod tests {209
FixedOffset::east_opt(0).unwrap()231
FixedOffset::east_opt(0).unwrap()210
}232
}211
233
234
#[test]235
fn channel_times_show_the_clock_today_then_day_and_month_then_the_year() {236
let style = Some(date_style("en-gb"));237
let label = |time| channel_time_label_in(style, time, today(), zero());238
assert_eq!(label(utc(7, 8)), "08:05");239
assert_eq!(label(utc(1, 8)), "01/10");240
assert_eq!(241
label(Utc.with_ymd_and_hms(2025, 10, 23, 8, 0, 0).unwrap()),242
"23/10/2025"243
);244
}245
212
#[test]246
#[test]213
fn palette_index_is_stable_and_in_range() {247
fn palette_index_is_stable_and_in_range() {214
assert_eq!(palette_index("user-1"), palette_index("user-1"));248
assert_eq!(palette_index("user-1"), palette_index("user-1"));@@ -114,6 +114,7 @@ pub const PRIYA_ID: &str = "demo-priya";
114
114
pub const LEA_ID: &str = "demo-lea";
115
115
pub const TOBIAS_ID: &str = "demo-tobias";
116
116
117
const DEMO_PRIVATE_CHANNEL: &str = "Runbooks";
117
118
const DEMO_TEAMS: [(&str, &str, [&str; 3]); 4] = [
118
119
(
119
120
"demo-team-1",
@@ -881,7 +882,7 @@ pub fn seed(store: &Store) {
881
882
id: format!("demo-channel-{}-{}", team_index + 1, channel_index + 1),
882
883
team_id: (*team_id).to_owned(),
883
884
name: (*name).to_owned(),
884
membership_type: None,
885
membership_type: (*name == DEMO_PRIVATE_CHANNEL).then(|| "private".to_owned()),
885
886
last_message_at: Some(at(channel_index as i64, 12, 10)),
886
887
unread: (team_index == 0 && channel_index == 1)
887
888
|| (team_index == 1 && channel_index == 0),
@@ -114,6 +114,7 @@ pub const PRIYA_ID: &str = "demo-priya";114
pub const LEA_ID: &str = "demo-lea";114
pub const LEA_ID: &str = "demo-lea";115
pub const TOBIAS_ID: &str = "demo-tobias";115
pub const TOBIAS_ID: &str = "demo-tobias";116
116
117
const DEMO_PRIVATE_CHANNEL: &str = "Runbooks";117
const DEMO_TEAMS: [(&str, &str, [&str; 3]); 4] = [118
const DEMO_TEAMS: [(&str, &str, [&str; 3]); 4] = [118
(119
(119
"demo-team-1",120
"demo-team-1",@@ -881,7 +882,7 @@ pub fn seed(store: &Store) {881
id: format!("demo-channel-{}-{}", team_index + 1, channel_index + 1),882
id: format!("demo-channel-{}-{}", team_index + 1, channel_index + 1),882
team_id: (*team_id).to_owned(),883
team_id: (*team_id).to_owned(),883
name: (*name).to_owned(),884
name: (*name).to_owned(),884
membership_type: None,885
membership_type: (*name == DEMO_PRIVATE_CHANNEL).then(|| "private".to_owned()),885
last_message_at: Some(at(channel_index as i64, 12, 10)),886
last_message_at: Some(at(channel_index as i64, 12, 10)),886
unread: (team_index == 0 && channel_index == 1)887
unread: (team_index == 0 && channel_index == 1)887
|| (team_index == 1 && channel_index == 0),888
|| (team_index == 1 && channel_index == 0),@@ -0,0 +1 @@
1
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M264.62-120q-26.85 0-45.74-18.88Q200-157.77 200-184.62v-350.76q0-26.85 18.88-45.74Q237.77-600 264.62-600H320v-80q0-66.85 46.58-113.42Q413.15-840 480-840t113.42 46.58Q640-746.85 640-680v80h55.38q26.85 0 45.74 18.88Q760-562.23 760-535.38v350.76q0 26.85-18.88 45.74Q722.23-120 695.38-120H264.62Zm0-40h430.76q10.77 0 17.7-6.92 6.92-6.93 6.92-17.7v-350.76q0-10.77-6.92-17.7-6.93-6.92-17.7-6.92H264.62q-10.77 0-17.7 6.92-6.92 6.93-6.92 17.7v350.76q0 10.77 6.92 17.7 6.93 6.92 17.7 6.92Zm258.03-157.35Q540-334.69 540-360t-17.35-42.65Q505.31-420 480-420t-42.65 17.35Q420-385.31 420-360t17.35 42.65Q454.69-300 480-300t42.65-17.35ZM360-600h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80ZM240-160v-400 400Z"/></svg>
@@ -0,0 +1 @@1
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M264.62-120q-26.85 0-45.74-18.88Q200-157.77 200-184.62v-350.76q0-26.85 18.88-45.74Q237.77-600 264.62-600H320v-80q0-66.85 46.58-113.42Q413.15-840 480-840t113.42 46.58Q640-746.85 640-680v80h55.38q26.85 0 45.74 18.88Q760-562.23 760-535.38v350.76q0 26.85-18.88 45.74Q722.23-120 695.38-120H264.62Zm0-40h430.76q10.77 0 17.7-6.92 6.92-6.93 6.92-17.7v-350.76q0-10.77-6.92-17.7-6.93-6.92-17.7-6.92H264.62q-10.77 0-17.7 6.92-6.92 6.93-6.92 17.7v350.76q0 10.77 6.92 17.7 6.93 6.92 17.7 6.92Zm258.03-157.35Q540-334.69 540-360t-17.35-42.65Q505.31-420 480-420t-42.65 17.35Q420-385.31 420-360t17.35 42.65Q454.69-300 480-300t42.65-17.35ZM360-600h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80ZM240-160v-400 400Z"/></svg>@@ -68,7 +68,16 @@ const PINNED_LABEL: &str = "Pinned";
68
68
const TEAMS_LABEL: &str = "Teams";
69
69
const MARK_ALL_READ_LABEL: &str = "Mark all as read";
70
70
const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";
71
const TEAM_ROW_HEIGHT: f32 = 40.;
71
const TEAM_ROW_HEIGHT: f32 = 36.;
72
const CHANNEL_ROW_HEIGHT: f32 = 32.;
73
const TEAM_ICON_SIZE: f32 = 20.;
74
const TEAM_ICON_RADIUS: f32 = 4.;
75
const CHANNEL_INDENT: f32 = 60.;
76
pub const CHANNEL_ROW_TAG: &str = "sidebar/channel-row";
77
pub const SEE_ALL_CHANNELS_TAG: &str = "sidebar/see-all-channels";
78
const SEE_ALL_CHANNELS: &str = "See all channels";
79
const SEE_FEWER_CHANNELS: &str = "See fewer channels";
80
const PRIVATE_MEMBERSHIP: &str = "private";
72
81
const REVEAL_ROW_HEIGHT: f32 = 32.;
73
82
const NEW_CHAT_BUTTON_SIZE: f32 = 32.;
74
83
const NOTIFICATION_ICON_SIZE: f32 = 13.;
@@ -1474,14 +1483,7 @@ impl SidebarView {
1474
1483
let menu_state = self.state.clone();
1475
1484
let menu_channel_id = channel_id.to_owned();
1476
1485
let selection = Selection::Channel(channel_id.to_owned());
1477
let now = Utc::now();
1478
let offset = Local::now().offset().fix();
1479
let time = channel
1480
.last_message_at
1481
.map(|time| {
1482
format::list_time_label(time, now.with_timezone(&offset).date_naive(), offset)
1483
})
1484
.unwrap_or_default();
1486
let time = channel_activity(channel);
1485
1487
h_flex()
1486
1488
.id(SharedString::from(format!("pinned-{channel_id}")))
1487
1489
.mx(px(6.))
@@ -1608,7 +1610,12 @@ impl SidebarView {
1608
1610
14.,
1609
1611
theme::text_muted(),
1610
1612
))
1611
.child(square_avatar(&entry.team.name, &entry.team.id, 28., 7.))
1613
.child(square_avatar(
1614
&entry.team.name,
1615
&entry.team.id,
1616
TEAM_ICON_SIZE,
1617
TEAM_ICON_RADIUS,
1618
))
1612
1619
.child(
1613
1620
div()
1614
1621
.flex_1()
@@ -1655,11 +1662,9 @@ impl SidebarView {
1655
1662
return list;
1656
1663
}
1657
1664
let toggle_id = team_id.clone();
1658
list = list.child(self.reveal_row(
1665
list = list.child(self.see_all_channels_row(
1659
1666
SharedString::from(format!("hidden-channels-{team_id}")),
1660
hidden_channels_label(rows.hidden_count),
1661
1667
revealed,
1662
40.,
1663
1668
cx.listener(move |this, _, _, cx| {
1664
1669
if !this.revealed_channel_teams.remove(&toggle_id) {
1665
1670
this.revealed_channel_teams.insert(toggle_id.clone());
@@ -1679,6 +1684,30 @@ impl SidebarView {
1679
1684
list
1680
1685
}
1681
1686
1687
fn see_all_channels_row(
1688
&self,
1689
id: SharedString,
1690
open: bool,
1691
on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
1692
) -> impl IntoElement {
1693
h_flex()
1694
.id(id)
1695
.debug_selector(|| SEE_ALL_CHANNELS_TAG.into())
1696
.mx(px(6.))
1697
.h(px(CHANNEL_ROW_HEIGHT))
1698
.flex_none()
1699
.pl(px(CHANNEL_INDENT))
1700
.pr(px(10.))
1701
.items_center()
1702
.rounded(px(8.))
1703
.cursor_pointer()
1704
.hover(|row| row.bg(theme::row_hover()))
1705
.text_size(px(13.5))
1706
.text_color(theme::accent_text())
1707
.child(if open { SEE_FEWER_CHANNELS } else { SEE_ALL_CHANNELS })
1708
.on_click(on_click)
1709
}
1710
1682
1711
fn reveal_row(
1683
1712
&self,
1684
1713
id: SharedString,
@@ -1731,10 +1760,11 @@ impl SidebarView {
1731
1760
let selection = Selection::Channel(channel.id.clone());
1732
1761
h_flex()
1733
1762
.id(SharedString::from(format!("channel-{}", channel.id)))
1763
.debug_selector(|| CHANNEL_ROW_TAG.into())
1734
1764
.mx(px(6.))
1735
.h(px(TEAM_ROW_HEIGHT))
1765
.h(px(CHANNEL_ROW_HEIGHT))
1736
1766
.flex_none()
1737
.pl(px(40.))
1767
.pl(px(CHANNEL_INDENT))
1738
1768
.pr(px(10.))
1739
1769
.gap(px(8.))
1740
1770
.items_center()
@@ -1745,25 +1775,36 @@ impl SidebarView {
1745
1775
row.hover(|row| row.bg(theme::row_hover()))
1746
1776
})
1747
1777
.child(
1748
div()
1749
.w(px(14.))
1750
.flex()
1751
.justify_center()
1752
.text_size(px(15.))
1753
.text_color(theme::text_faint())
1754
.child("#"),
1755
)
1756
.child(
1757
div()
1778
h_flex()
1758
1779
.flex_1()
1759
1780
.min_w_0()
1760
.truncate()
1761
.text_size(px(13.5))
1762
.font_weight(name_weight(name_style))
1763
.text_color(name_color(name_style))
1764
.child(channel.name.clone()),
1781
.gap(px(4.))
1782
.items_center()
1783
.child(
1784
div()
1785
.min_w_0()
1786
.truncate()
1787
.text_size(px(13.5))
1788
.font_weight(name_weight(name_style))
1789
.text_color(name_color(name_style))
1790
.child(channel.name.clone()),
1791
)
1792
.when(is_private_channel(channel), |name| {
1793
name.child(
1794
div()
1795
.flex_none()
1796
.child(symbol("lock", 14., theme::text_muted())),
1797
)
1798
}),
1765
1799
)
1766
1800
.children(notification_badge(notifications.level))
1801
.child(
1802
div()
1803
.flex_none()
1804
.text_size(px(11.))
1805
.text_color(theme::text_muted())
1806
.child(channel_activity(channel)),
1807
)
1767
1808
.children(badge.map(mention_badge))
1768
1809
.on_click(move |_, _, cx| {
1769
1810
let selection = selection.clone();
@@ -2079,12 +2120,21 @@ fn team_holds(entry: &SidebarTeam, selected: Option<&Selection>) -> bool {
2079
2120
.any(|channel| selected == Some(&Selection::Channel(channel.id.clone())))
2080
2121
}
2081
2122
2082
fn hidden_channels_label(count: usize) -> String {
2083
if count == 1 {
2084
"1 hidden channel".to_owned()
2085
} else {
2086
format!("{count} hidden channels")
2087
}
2123
fn is_private_channel(channel: &ChannelRecord) -> bool {
2124
channel
2125
.membership_type
2126
.as_deref()
2127
.is_some_and(|membership| membership.eq_ignore_ascii_case(PRIVATE_MEMBERSHIP))
2128
}
2129
2130
fn channel_activity(channel: &ChannelRecord) -> String {
2131
let offset = Local::now().offset().fix();
2132
channel
2133
.last_message_at
2134
.map(|time| {
2135
format::channel_time_label(time, Utc::now().with_timezone(&offset).date_naive(), offset)
2136
})
2137
.unwrap_or_default()
2088
2138
}
2089
2139
2090
2140
fn collect_faces(spec: &AvatarSpec, faces: &mut Vec<String>) {
@@ -68,7 +68,16 @@ const PINNED_LABEL: &str = "Pinned";68
const TEAMS_LABEL: &str = "Teams";68
const TEAMS_LABEL: &str = "Teams";69
const MARK_ALL_READ_LABEL: &str = "Mark all as read";69
const MARK_ALL_READ_LABEL: &str = "Mark all as read";70
const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";70
const HIDDEN_TEAMS_LABEL: &str = "Hidden teams";71
const TEAM_ROW_HEIGHT: f32 = 40.;71
const TEAM_ROW_HEIGHT: f32 = 36.;72
const CHANNEL_ROW_HEIGHT: f32 = 32.;73
const TEAM_ICON_SIZE: f32 = 20.;74
const TEAM_ICON_RADIUS: f32 = 4.;75
const CHANNEL_INDENT: f32 = 60.;76
pub const CHANNEL_ROW_TAG: &str = "sidebar/channel-row";77
pub const SEE_ALL_CHANNELS_TAG: &str = "sidebar/see-all-channels";78
const SEE_ALL_CHANNELS: &str = "See all channels";79
const SEE_FEWER_CHANNELS: &str = "See fewer channels";80
const PRIVATE_MEMBERSHIP: &str = "private";72
const REVEAL_ROW_HEIGHT: f32 = 32.;81
const REVEAL_ROW_HEIGHT: f32 = 32.;73
const NEW_CHAT_BUTTON_SIZE: f32 = 32.;82
const NEW_CHAT_BUTTON_SIZE: f32 = 32.;74
const NOTIFICATION_ICON_SIZE: f32 = 13.;83
const NOTIFICATION_ICON_SIZE: f32 = 13.;@@ -1474,14 +1483,7 @@ impl SidebarView {1474
let menu_state = self.state.clone();1483
let menu_state = self.state.clone();1475
let menu_channel_id = channel_id.to_owned();1484
let menu_channel_id = channel_id.to_owned();1476
let selection = Selection::Channel(channel_id.to_owned());1485
let selection = Selection::Channel(channel_id.to_owned());1477
let now = Utc::now();1486
let time = channel_activity(channel);1478
let offset = Local::now().offset().fix();1479
let time = channel1480
.last_message_at1481
.map(|time| {1482
format::list_time_label(time, now.with_timezone(&offset).date_naive(), offset)1483
})1484
.unwrap_or_default();1485
h_flex()1487
h_flex()1486
.id(SharedString::from(format!("pinned-{channel_id}")))1488
.id(SharedString::from(format!("pinned-{channel_id}")))1487
.mx(px(6.))1489
.mx(px(6.))@@ -1608,7 +1610,12 @@ impl SidebarView {1608
14.,1610
14.,1609
theme::text_muted(),1611
theme::text_muted(),1610
))1612
))1611
.child(square_avatar(&entry.team.name, &entry.team.id, 28., 7.))1613
.child(square_avatar(1614
&entry.team.name,1615
&entry.team.id,1616
TEAM_ICON_SIZE,1617
TEAM_ICON_RADIUS,1618
))1612
.child(1619
.child(1613
div()1620
div()1614
.flex_1()1621
.flex_1()@@ -1655,11 +1662,9 @@ impl SidebarView {1655
return list;1662
return list;1656
}1663
}1657
let toggle_id = team_id.clone();1664
let toggle_id = team_id.clone();1658
list = list.child(self.reveal_row(1665
list = list.child(self.see_all_channels_row(1659
SharedString::from(format!("hidden-channels-{team_id}")),1666
SharedString::from(format!("hidden-channels-{team_id}")),1660
hidden_channels_label(rows.hidden_count),1661
revealed,1667
revealed,1662
40.,1663
cx.listener(move |this, _, _, cx| {1668
cx.listener(move |this, _, _, cx| {1664
if !this.revealed_channel_teams.remove(&toggle_id) {1669
if !this.revealed_channel_teams.remove(&toggle_id) {1665
this.revealed_channel_teams.insert(toggle_id.clone());1670
this.revealed_channel_teams.insert(toggle_id.clone());@@ -1679,6 +1684,30 @@ impl SidebarView {1679
list1684
list1680
}1685
}1681
1686
1687
fn see_all_channels_row(1688
&self,1689
id: SharedString,1690
open: bool,1691
on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,1692
) -> impl IntoElement {1693
h_flex()1694
.id(id)1695
.debug_selector(|| SEE_ALL_CHANNELS_TAG.into())1696
.mx(px(6.))1697
.h(px(CHANNEL_ROW_HEIGHT))1698
.flex_none()1699
.pl(px(CHANNEL_INDENT))1700
.pr(px(10.))1701
.items_center()1702
.rounded(px(8.))1703
.cursor_pointer()1704
.hover(|row| row.bg(theme::row_hover()))1705
.text_size(px(13.5))1706
.text_color(theme::accent_text())1707
.child(if open { SEE_FEWER_CHANNELS } else { SEE_ALL_CHANNELS })1708
.on_click(on_click)1709
}1710
1682
fn reveal_row(1711
fn reveal_row(1683
&self,1712
&self,1684
id: SharedString,1713
id: SharedString,@@ -1731,10 +1760,11 @@ impl SidebarView {1731
let selection = Selection::Channel(channel.id.clone());1760
let selection = Selection::Channel(channel.id.clone());1732
h_flex()1761
h_flex()1733
.id(SharedString::from(format!("channel-{}", channel.id)))1762
.id(SharedString::from(format!("channel-{}", channel.id)))1763
.debug_selector(|| CHANNEL_ROW_TAG.into())1734
.mx(px(6.))1764
.mx(px(6.))1735
.h(px(TEAM_ROW_HEIGHT))1765
.h(px(CHANNEL_ROW_HEIGHT))1736
.flex_none()1766
.flex_none()1737
.pl(px(40.))1767
.pl(px(CHANNEL_INDENT))1738
.pr(px(10.))1768
.pr(px(10.))1739
.gap(px(8.))1769
.gap(px(8.))1740
.items_center()1770
.items_center()@@ -1745,25 +1775,36 @@ impl SidebarView {1745
row.hover(|row| row.bg(theme::row_hover()))1775
row.hover(|row| row.bg(theme::row_hover()))1746
})1776
})1747
.child(1777
.child(1748
div()1778
h_flex()1749
.w(px(14.))1750
.flex()1751
.justify_center()1752
.text_size(px(15.))1753
.text_color(theme::text_faint())1754
.child("#"),1755
)1756
.child(1757
div()1758
.flex_1()1779
.flex_1()1759
.min_w_0()1780
.min_w_0()1760
.truncate()1781
.gap(px(4.))1761
.text_size(px(13.5))1782
.items_center()1762
.font_weight(name_weight(name_style))1783
.child(1763
.text_color(name_color(name_style))1784
div()1764
.child(channel.name.clone()),1785
.min_w_0()1786
.truncate()1787
.text_size(px(13.5))1788
.font_weight(name_weight(name_style))1789
.text_color(name_color(name_style))1790
.child(channel.name.clone()),1791
)1792
.when(is_private_channel(channel), |name| {1793
name.child(1794
div()1795
.flex_none()1796
.child(symbol("lock", 14., theme::text_muted())),1797
)1798
}),1765
)1799
)1766
.children(notification_badge(notifications.level))1800
.children(notification_badge(notifications.level))1801
.child(1802
div()1803
.flex_none()1804
.text_size(px(11.))1805
.text_color(theme::text_muted())1806
.child(channel_activity(channel)),1807
)1767
.children(badge.map(mention_badge))1808
.children(badge.map(mention_badge))1768
.on_click(move |_, _, cx| {1809
.on_click(move |_, _, cx| {1769
let selection = selection.clone();1810
let selection = selection.clone();@@ -2079,12 +2120,21 @@ fn team_holds(entry: &SidebarTeam, selected: Option<&Selection>) -> bool {2079
.any(|channel| selected == Some(&Selection::Channel(channel.id.clone())))2120
.any(|channel| selected == Some(&Selection::Channel(channel.id.clone())))2080
}2121
}2081
2122
2082
fn hidden_channels_label(count: usize) -> String {2123
fn is_private_channel(channel: &ChannelRecord) -> bool {2083
if count == 1 {2124
channel2084
"1 hidden channel".to_owned()2125
.membership_type2085
} else {2126
.as_deref()2086
format!("{count} hidden channels")2127
.is_some_and(|membership| membership.eq_ignore_ascii_case(PRIVATE_MEMBERSHIP))2087
}2128
}2129
2130
fn channel_activity(channel: &ChannelRecord) -> String {2131
let offset = Local::now().offset().fix();2132
channel2133
.last_message_at2134
.map(|time| {2135
format::channel_time_label(time, Utc::now().with_timezone(&offset).date_naive(), offset)2136
})2137
.unwrap_or_default()2088
}2138
}2089
2139
2090
fn collect_faces(spec: &AvatarSpec, faces: &mut Vec<String>) {2140
fn collect_faces(spec: &AvatarSpec, faces: &mut Vec<String>) {