Add hover styles to channels matching the current selection
Fix chat desync from moving / linking channels
This commit is contained in:
parent
d5f0ce0e20
commit
ac65e7590c
8 changed files with 284 additions and 94 deletions
|
@ -146,17 +146,26 @@ impl ChannelStore {
|
|||
})
|
||||
}
|
||||
|
||||
/// Returns the number of unique channels in the store
|
||||
pub fn channel_count(&self) -> usize {
|
||||
self.channel_index.len()
|
||||
self.channel_index.by_id().len()
|
||||
}
|
||||
|
||||
/// Returns the index of a channel ID in the list of unique channels
|
||||
pub fn index_of_channel(&self, channel_id: ChannelId) -> Option<usize> {
|
||||
self.channel_index
|
||||
.iter()
|
||||
.position(|path| path.ends_with(&[channel_id]))
|
||||
.by_id()
|
||||
.keys()
|
||||
.position(|id| *id == channel_id)
|
||||
}
|
||||
|
||||
pub fn channels(&self) -> impl '_ + Iterator<Item = (usize, &Arc<Channel>)> {
|
||||
/// Returns an iterator over all unique channels
|
||||
pub fn channels(&self) -> impl '_ + Iterator<Item = &Arc<Channel>> {
|
||||
self.channel_index.by_id().values()
|
||||
}
|
||||
|
||||
/// Iterate over all entries in the channel DAG
|
||||
pub fn channel_dag_entries(&self) -> impl '_ + Iterator<Item = (usize, &Arc<Channel>)> {
|
||||
self.channel_index.iter().map(move |path| {
|
||||
let id = path.last().unwrap();
|
||||
let channel = self.channel_for_id(*id).unwrap();
|
||||
|
@ -164,7 +173,7 @@ impl ChannelStore {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn channel_at_index(&self, ix: usize) -> Option<(&Arc<Channel>, &ChannelPath)> {
|
||||
pub fn channel_dag_entry_at(&self, ix: usize) -> Option<(&Arc<Channel>, &ChannelPath)> {
|
||||
let path = self.channel_index.get(ix)?;
|
||||
let id = path.last().unwrap();
|
||||
let channel = self.channel_for_id(*id).unwrap();
|
||||
|
@ -172,6 +181,10 @@ impl ChannelStore {
|
|||
Some((channel, path))
|
||||
}
|
||||
|
||||
pub fn channel_at(&self, ix: usize) -> Option<&Arc<Channel>> {
|
||||
self.channel_index.by_id().values().nth(ix)
|
||||
}
|
||||
|
||||
pub fn channel_invitations(&self) -> &[Arc<Channel>] {
|
||||
&self.channel_invitations
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue