unique channel names (#8439)
Before this change duplicate channels were ordered arbitrarily, which put the collab channel in an inconsistent state. Release Notes: - Fixed duplicate channel names appearing in the collab sidebar.
This commit is contained in:
parent
a44fc24445
commit
f27d59896f
2 changed files with 9 additions and 3 deletions
|
@ -94,14 +94,17 @@ impl<'a> Drop for ChannelPathsInsertGuard<'a> {
|
||||||
fn channel_path_sorting_key<'a>(
|
fn channel_path_sorting_key<'a>(
|
||||||
id: ChannelId,
|
id: ChannelId,
|
||||||
channels_by_id: &'a BTreeMap<ChannelId, Arc<Channel>>,
|
channels_by_id: &'a BTreeMap<ChannelId, Arc<Channel>>,
|
||||||
) -> impl Iterator<Item = &str> {
|
) -> impl Iterator<Item = (&str, u64)> {
|
||||||
let (parent_path, name) = channels_by_id
|
let (parent_path, name) = channels_by_id
|
||||||
.get(&id)
|
.get(&id)
|
||||||
.map_or((&[] as &[_], None), |channel| {
|
.map_or((&[] as &[_], None), |channel| {
|
||||||
(channel.parent_path.as_slice(), Some(channel.name.as_ref()))
|
(
|
||||||
|
channel.parent_path.as_slice(),
|
||||||
|
Some((channel.name.as_ref(), channel.id)),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
parent_path
|
parent_path
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|id| Some(channels_by_id.get(id)?.name.as_ref()))
|
.filter_map(|id| Some((channels_by_id.get(id)?.name.as_ref(), *id)))
|
||||||
.chain(name)
|
.chain(name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Add migration script here
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX uix_channels_parent_path_name ON channels(parent_path, name) WHERE (parent_path IS NOT NULL);
|
Loading…
Add table
Add a link
Reference in a new issue