Use consistent Display Name sorting code throughout the webapp #5159 (#5213)

* Use consistent Display Name sorting code throughout the webapp #5159

* fixed broken sorting of teams and channels
Этот коммит содержится в:
Saturnino Abril
2017-02-01 08:57:16 +09:00
коммит произвёл enahum
родитель 9369cab56c
Коммит 9ba968ce33
11 изменённых файлов: 51 добавлений и 90 удалений

Просмотреть файл

@@ -10,6 +10,7 @@ import ChannelStore from 'stores/channel_store.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {Constants, ActionTypes} from 'utils/constants.jsx';
import {sortChannelsByDisplayName} from 'utils/channel_utils.jsx';
import React from 'react';
@@ -51,7 +52,7 @@ export default class SearchChannelProvider extends Provider {
const publicChannels = data;
const localChannels = ChannelStore.getAll();
const privateChannels = [];
let privateChannels = [];
for (const id of Object.keys(localChannels)) {
const channel = localChannels[id];
@@ -60,15 +61,15 @@ export default class SearchChannelProvider extends Provider {
}
}
const filteredPublicChannels = [];
let filteredPublicChannels = [];
publicChannels.forEach((item) => {
if (item.name.startsWith(channelPrefix)) {
filteredPublicChannels.push(item);
}
});
privateChannels.sort((a, b) => a.name.localeCompare(b.name));
filteredPublicChannels.sort((a, b) => a.name.localeCompare(b.name));
privateChannels = privateChannels.sort(sortChannelsByDisplayName);
filteredPublicChannels = filteredPublicChannels.sort(sortChannelsByDisplayName);
const channels = filteredPublicChannels.concat(privateChannels);
const channelNames = channels.map((channel) => channel.name);

Просмотреть файл

@@ -12,6 +12,7 @@ import Client from 'client/web_client.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {Constants, ActionTypes} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import {sortChannelsByDisplayName} from 'utils/channel_utils.jsx';
import React from 'react';
@@ -105,19 +106,9 @@ export default class SwitchChannelProvider extends Provider {
userMap[user.id] = user;
}
channels.sort((a, b) => {
if (a.display_name === b.display_name) {
if (a.type !== Constants.DM_CHANNEL && b.type === Constants.DM_CHANNEL) {
return -1;
} else if (a.type === Constants.DM_CHANNEL && b.type !== Constants.DM_CHANNEL) {
return 1;
}
return a.name.localeCompare(b.name);
}
return a.display_name.localeCompare(b.display_name);
});
const channelNames = channels.map((channel) => channel.name);
const channelNames = channels.
sort(sortChannelsByDisplayName).
map((channel) => channel.name);
AppDispatcher.handleServerAction({
type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,