PLT-4614 Fix ordering of channels. (#4980)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
3076a5c4bd
Коммит
0c0635d766
@@ -76,10 +76,21 @@ export function completeDirectChannelInfo(channel) {
|
||||
});
|
||||
}
|
||||
|
||||
const defaultPrefix = 'D'; // fallback for future types
|
||||
const typeToPrefixMap = {[Constants.OPEN_CHANNEL]: 'A', [Constants.PRIVATE_CHANNEL]: 'B', [Constants.DM_CHANNEL]: 'C'};
|
||||
|
||||
export function sortChannelsByDisplayName(a, b) {
|
||||
const locale = LocalizationStore.getLocale();
|
||||
|
||||
return buildDisplayNameAndTypeComparable(a).localeCompare(buildDisplayNameAndTypeComparable(b), locale, {numeric: true});
|
||||
if (a.type !== b.type) {
|
||||
return (typeToPrefixMap[a.type] || defaultPrefix).localeCompare((typeToPrefixMap[b.type] || defaultPrefix), locale);
|
||||
}
|
||||
|
||||
if (a.display_name !== b.display_name) {
|
||||
return a.display_name.localeCompare(b.display_name, locale, {numeric: true});
|
||||
}
|
||||
|
||||
return a.name.localeCompare(b.name, locale, {numeric: true});
|
||||
}
|
||||
|
||||
export function showCreateOption(channelType, isAdmin, isSystemAdmin) {
|
||||
@@ -200,10 +211,3 @@ function not(f) {
|
||||
function andX(...fns) {
|
||||
return (...args) => fns.every((f) => f(...args));
|
||||
}
|
||||
|
||||
const defaultPrefix = 'D'; // fallback for future types
|
||||
const typeToPrefixMap = {[Constants.OPEN_CHANNEL]: 'A', [Constants.PRIVATE_CHANNEL]: 'B', [Constants.DM_CHANNEL]: 'C'};
|
||||
|
||||
function buildDisplayNameAndTypeComparable(channel) {
|
||||
return (typeToPrefixMap[channel.type] || defaultPrefix) + channel.display_name + channel.name;
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user