remove extraneous depth field
This commit is contained in:
@@ -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 path = self.channel_index.get(ix)?;
|
||||||
let id = path.last().unwrap();
|
let id = path.last().unwrap();
|
||||||
let channel = self.channel_for_id(*id).unwrap();
|
let channel = self.channel_for_id(*id).unwrap();
|
||||||
|
|
||||||
|
Some((channel, path))
|
||||||
Some((path.len() - 1, channel, path))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn channel_invitations(&self) -> &[Arc<Channel>] {
|
pub fn channel_invitations(&self) -> &[Arc<Channel>] {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::{ops::Deref, sync::Arc};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use rpc::proto;
|
use rpc::proto;
|
||||||
@@ -25,6 +25,18 @@ impl ChannelIndex {
|
|||||||
self.channels_by_id.clear();
|
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
|
/// Remove the given edge from this index. This will not remove the channel
|
||||||
/// and may result in dangling channels.
|
/// and may result in dangling channels.
|
||||||
pub fn delete_edge(&mut self, parent_id: ChannelId, channel_id: ChannelId) {
|
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
|
/// A guard for ensuring that the paths index maintains its sort and uniqueness
|
||||||
/// invariants after a series of insertions
|
/// invariants after a series of insertions
|
||||||
pub struct ChannelPathsUpsertGuard<'a> {
|
pub struct ChannelPathsUpsertGuard<'a> {
|
||||||
|
|||||||
@@ -785,8 +785,9 @@ impl CollabPanel {
|
|||||||
}
|
}
|
||||||
let mut collapse_depth = None;
|
let mut collapse_depth = None;
|
||||||
for mat in matches {
|
for mat in matches {
|
||||||
let (depth, channel, path) =
|
let (channel, path) =
|
||||||
channel_store.channel_at_index(mat.candidate_id).unwrap();
|
channel_store.channel_at_index(mat.candidate_id).unwrap();
|
||||||
|
let depth = path.len() - 1;
|
||||||
|
|
||||||
let location: ChannelLocation<'_> = (channel.id, path).into();
|
let location: ChannelLocation<'_> = (channel.id, path).into();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user