remove extraneous depth field

This commit is contained in:
Mikayla
2023-09-09 12:10:18 -07:00
parent 8222102d01
commit 77cdbdb12a
3 changed files with 17 additions and 13 deletions

View File

@@ -146,13 +146,12 @@ impl ChannelStore {
})
}
pub fn channel_at_index(&self, ix: usize) -> Option<(usize, &Arc<Channel>, &Arc<[ChannelId]>)> {
pub fn channel_at_index(&self, ix: usize) -> Option<(&Arc<Channel>, &Arc<[ChannelId]>)> {
let path = self.channel_index.get(ix)?;
let id = path.last().unwrap();
let channel = self.channel_for_id(*id).unwrap();
Some((path.len() - 1, channel, path))
Some((channel, path))
}
pub fn channel_invitations(&self) -> &[Arc<Channel>] {

View File

@@ -1,4 +1,4 @@
use std::{ops::Deref, sync::Arc};
use std::sync::Arc;
use collections::HashMap;
use rpc::proto;
@@ -25,6 +25,18 @@ impl ChannelIndex {
self.channels_by_id.clear();
}
pub fn len(&self) -> usize {
self.paths.len()
}
pub fn get(&self, idx: usize) -> Option<&ChannelPath> {
self.paths.get(idx)
}
pub fn iter(&self) -> impl Iterator<Item = &ChannelPath> {
self.paths.iter()
}
/// Remove the given edge from this index. This will not remove the channel
/// and may result in dangling channels.
pub fn delete_edge(&mut self, parent_id: ChannelId, channel_id: ChannelId) {
@@ -50,14 +62,6 @@ impl ChannelIndex {
}
}
impl Deref for ChannelIndex {
type Target = Vec<ChannelPath>;
fn deref(&self) -> &Self::Target {
&self.paths
}
}
/// A guard for ensuring that the paths index maintains its sort and uniqueness
/// invariants after a series of insertions
pub struct ChannelPathsUpsertGuard<'a> {

View File

@@ -785,8 +785,9 @@ impl CollabPanel {
}
let mut collapse_depth = None;
for mat in matches {
let (depth, channel, path) =
let (channel, path) =
channel_store.channel_at_index(mat.candidate_id).unwrap();
let depth = path.len() - 1;
let location: ChannelLocation<'_> = (channel.id, path).into();