[FIX] Rooms grouping not working properly (#1435)
This commit is contained in:
parent
7cdf6394fc
commit
224ff5fe44
|
@ -67,6 +67,9 @@ const CHANNELS_HEADER = 'Channels';
|
||||||
const DM_HEADER = 'Direct_Messages';
|
const DM_HEADER = 'Direct_Messages';
|
||||||
const GROUPS_HEADER = 'Private_Groups';
|
const GROUPS_HEADER = 'Private_Groups';
|
||||||
|
|
||||||
|
const filterIsUnread = s => (s.unread > 0 || s.alert) && !s.hideUnreadStatus;
|
||||||
|
const filterIsFavorite = s => s.f;
|
||||||
|
|
||||||
const shouldUpdateProps = [
|
const shouldUpdateProps = [
|
||||||
'searchText',
|
'searchText',
|
||||||
'loadingServer',
|
'loadingServer',
|
||||||
|
@ -404,14 +407,16 @@ class RoomsListView extends React.Component {
|
||||||
|
|
||||||
// unread
|
// unread
|
||||||
if (showUnread) {
|
if (showUnread) {
|
||||||
const unread = chats.filter(s => (s.unread > 0 || s.alert) && !s.hideUnreadStatus);
|
const unread = chats.filter(s => filterIsUnread(s));
|
||||||
|
chats = chats.filter(s => !filterIsUnread(s));
|
||||||
tempChats = this.addRoomsGroup(unread, UNREAD_HEADER, tempChats);
|
tempChats = this.addRoomsGroup(unread, UNREAD_HEADER, tempChats);
|
||||||
}
|
}
|
||||||
|
|
||||||
// favorites
|
// favorites
|
||||||
if (showFavorites) {
|
if (showFavorites) {
|
||||||
const favorites = chats.filter(s => s.f);
|
const favorites = chats.filter(s => filterIsFavorite(s));
|
||||||
tempChats = this.addRoomsGroup(favorites, FAVORITES_HEADER, tempChats);
|
chats = chats.filter(s => !filterIsFavorite(s));
|
||||||
|
tempChats = this.addRoomsGroup(favorites, FAVORITES_HEADER, tempChats);
|
||||||
}
|
}
|
||||||
|
|
||||||
// type
|
// type
|
||||||
|
@ -420,18 +425,14 @@ class RoomsListView extends React.Component {
|
||||||
const channels = chats.filter(s => s.t === 'c' && !s.prid);
|
const channels = chats.filter(s => s.t === 'c' && !s.prid);
|
||||||
const privateGroup = chats.filter(s => s.t === 'p' && !s.prid);
|
const privateGroup = chats.filter(s => s.t === 'p' && !s.prid);
|
||||||
const direct = chats.filter(s => s.t === 'd' && !s.prid);
|
const direct = chats.filter(s => s.t === 'd' && !s.prid);
|
||||||
tempChats = this.addRoomsGroup(discussions, DISCUSSIONS_HEADER, tempChats);
|
tempChats = this.addRoomsGroup(discussions, DISCUSSIONS_HEADER, tempChats);
|
||||||
tempChats = this.addRoomsGroup(channels, CHANNELS_HEADER, tempChats);
|
tempChats = this.addRoomsGroup(channels, CHANNELS_HEADER, tempChats);
|
||||||
tempChats = this.addRoomsGroup(privateGroup, GROUPS_HEADER, tempChats);
|
tempChats = this.addRoomsGroup(privateGroup, GROUPS_HEADER, tempChats);
|
||||||
tempChats = this.addRoomsGroup(direct, DM_HEADER, tempChats);
|
tempChats = this.addRoomsGroup(direct, DM_HEADER, tempChats);
|
||||||
} else if (showUnread) {
|
} else if (showUnread || showFavorites) {
|
||||||
chats = chats.filter(s => (!s.unread && !s.alert) || s.hideUnreadStatus);
|
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
|
||||||
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
|
|
||||||
} else if (showFavorites) {
|
|
||||||
chats = chats.filter(s => !s.f);
|
|
||||||
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
|
|
||||||
} else {
|
} else {
|
||||||
tempChats = chats;
|
tempChats = chats;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.internalSetState({
|
this.internalSetState({
|
||||||
|
|
Loading…
Reference in New Issue