Prune dead code and key elements by stable ids
This commit is contained in:
@@ -105,10 +105,7 @@ impl Sidebar {
|
||||
rows.get(range.clone())
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.enumerate()
|
||||
.map(|(offset, row)| {
|
||||
let index = range.start + offset;
|
||||
|
||||
.map(|row| {
|
||||
let element = match row {
|
||||
SidebarRow::Section(section) => {
|
||||
let section = *section;
|
||||
@@ -181,7 +178,7 @@ impl Sidebar {
|
||||
let dock = self.dock.clone();
|
||||
let room = room.clone();
|
||||
|
||||
let nav = Nav::new(index)
|
||||
let nav = Nav::new(id)
|
||||
.label(name)
|
||||
.text_sm()
|
||||
.when(!hide_avatar, |this| {
|
||||
@@ -220,7 +217,7 @@ impl Sidebar {
|
||||
});
|
||||
|
||||
div()
|
||||
.id(index)
|
||||
.id(id)
|
||||
.w_full()
|
||||
.child(nav)
|
||||
.context_menu(move |menu, _window, _cx| {
|
||||
@@ -251,7 +248,7 @@ impl Sidebar {
|
||||
let sidebar = cx.entity().downgrade();
|
||||
let public_key = public_key.to_owned();
|
||||
|
||||
Nav::new(index)
|
||||
Nav::new(public_key.to_hex())
|
||||
.label(person.name())
|
||||
.text_sm()
|
||||
.when(!hide_avatar, |this| {
|
||||
@@ -275,7 +272,7 @@ impl Sidebar {
|
||||
let person = self.directory.read(cx).person(public_key, cx);
|
||||
let public_key = public_key.to_owned();
|
||||
|
||||
Nav::new(index)
|
||||
Nav::new(public_key.to_hex())
|
||||
.label(person.name())
|
||||
.text_sm()
|
||||
.when(!hide_avatar, |this| {
|
||||
@@ -308,7 +305,7 @@ impl Sidebar {
|
||||
.or_else(|| group.read(cx).elsewhere().map(|_| "Moved"))
|
||||
.map(SharedString::from);
|
||||
|
||||
let nav = Nav::new(index)
|
||||
let nav = Nav::new(tag.clone())
|
||||
.label(name)
|
||||
.text_sm()
|
||||
.when(!hide_avatar, |this| {
|
||||
@@ -347,7 +344,7 @@ impl Sidebar {
|
||||
});
|
||||
|
||||
div()
|
||||
.id(index)
|
||||
.id(tag.clone())
|
||||
.w_full()
|
||||
.child(nav)
|
||||
.context_menu(move |menu, _window, _cx| {
|
||||
@@ -383,8 +380,15 @@ impl Sidebar {
|
||||
let dock = self.dock.clone();
|
||||
let room = hit.room.clone();
|
||||
let content = hit.content.clone();
|
||||
// Several hits can share a room, so the id digests the whole hit
|
||||
let hit_id = common::stable_id_u64(&[
|
||||
hit.room.read(cx).id.to_string().as_str(),
|
||||
hit.author.to_string().as_str(),
|
||||
hit.created_at.as_secs().to_string().as_str(),
|
||||
hit.content.as_ref(),
|
||||
]);
|
||||
|
||||
Nav::new(index)
|
||||
Nav::new(hit_id)
|
||||
.label(content)
|
||||
.text_sm()
|
||||
.font_medium()
|
||||
|
||||
Reference in New Issue
Block a user