MM-19991 Filtering search by channel should also show the channel name and not only its ID (#3561)

This commit is contained in:
Elias Nahum 2019-11-18 12:56:01 -03:00 committed by Saturnino Abril
parent 00874eb3ff
commit b2e657b159
2 changed files with 12 additions and 12 deletions

View file

@ -20,7 +20,7 @@ function mapStateToProps(state, ownProps) {
let isBot = false;
let isGuest = false;
if (channel.type === General.DM_CHANNEL) {
if (channel?.type === General.DM_CHANNEL) {
const teammate = getUser(state, channel.teammate_id);
if (teammate) {
displayName = teammate.username;
@ -31,8 +31,8 @@ function mapStateToProps(state, ownProps) {
return {
displayName,
name: channel.name,
type: channel.type,
name: channel?.name,
type: channel?.type,
isBot,
isGuest,
theme: getTheme(state),

View file

@ -48,11 +48,11 @@ export const getMatchTermForChannelMention = (() => {
lastIsSearch = isSearch;
if (match) {
if (isSearch) {
lastMatchTerm = match[1];
lastMatchTerm = match[1].toLowerCase();
} else if (match.index > 0 && value[match.index - 1] === '~') {
lastMatchTerm = null;
} else {
lastMatchTerm = match[2];
lastMatchTerm = match[2].toLowerCase();
}
} else {
lastMatchTerm = null;
@ -152,7 +152,7 @@ export const filterMyChannels = createSelector(
if (matchTerm) {
channels = myChannels.filter((c) => {
return (c.type === General.OPEN_CHANNEL || c.type === General.PRIVATE_CHANNEL) &&
(c.name.startsWith(matchTerm) || c.display_name.startsWith(matchTerm));
(c.name.toLowerCase().startsWith(matchTerm) || c.display_name.toLowerCase().startsWith(matchTerm));
});
} else {
channels = myChannels.filter((c) => {
@ -175,7 +175,7 @@ export const filterOtherChannels = createSelector(
let channels;
if (matchTerm) {
channels = otherChannels.filter((c) => {
return (c.name.startsWith(matchTerm) || c.display_name.startsWith(matchTerm));
return (c.name.toLowerCase().startsWith(matchTerm) || c.display_name.toLowerCase().startsWith(matchTerm));
});
} else {
channels = otherChannels;
@ -200,9 +200,9 @@ export const filterPublicChannels = createSelector(
if (matchTerm) {
channels = myChannels.filter((c) => {
return c.type === General.OPEN_CHANNEL &&
(c.name.startsWith(matchTerm) || c.display_name.startsWith(matchTerm));
(c.name.toLowerCase().startsWith(matchTerm) || c.display_name.toLowerCase().startsWith(matchTerm));
}).concat(
otherChannels.filter((c) => c.name.startsWith(matchTerm) || c.display_name.startsWith(matchTerm))
otherChannels.filter((c) => c.name.toLowerCase().startsWith(matchTerm) || c.display_name.toLowerCase().startsWith(matchTerm))
);
} else {
channels = myChannels.filter((c) => {
@ -232,7 +232,7 @@ export const filterPrivateChannels = createSelector(
if (matchTerm) {
channels = myChannels.filter((c) => {
return c.type === General.PRIVATE_CHANNEL &&
(c.name.startsWith(matchTerm) || c.display_name.startsWith(matchTerm));
(c.name.toLowerCase().startsWith(matchTerm) || c.display_name.toLowerCase().startsWith(matchTerm));
});
} else {
channels = myChannels.filter((c) => {
@ -261,10 +261,10 @@ export const filterDirectAndGroupMessages = createSelector(
let channels;
if (matchTerm) {
channels = myChannels.filter((c) => {
if (c.type === General.DM_CHANNEL && (originalChannels[c.id].display_name.startsWith(matchTerm))) {
if (c.type === General.DM_CHANNEL && (originalChannels[c.id].display_name.toLowerCase().startsWith(matchTerm))) {
return true;
}
if (c.type === General.GM_CHANNEL && (c.name.startsWith(matchTerm) || c.display_name.replace(/ /g, '').startsWith(matchTerm))) {
if (c.type === General.GM_CHANNEL && (c.name.toLowerCase().startsWith(matchTerm) || c.display_name.toLowerCase().replace(/ /g, '').startsWith(matchTerm))) {
return true;
}
return false;