Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions app/views/RoomsListView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const CHANNELS_HEADER = 'Channels';
const DM_HEADER = 'Direct_Messages';
const GROUPS_HEADER = 'Private_Groups';

const filterIsUnread = s => (s.unread > 0 || s.alert) && !s.hideUnreadStatus;
const filterIsFavorite = s => s.f;

const shouldUpdateProps = [
'searchText',
'loadingServer',
Expand Down Expand Up @@ -404,14 +407,16 @@ class RoomsListView extends React.Component {

// unread
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);
}

// favorites
if (showFavorites) {
const favorites = chats.filter(s => s.f);
tempChats = this.addRoomsGroup(favorites, FAVORITES_HEADER, tempChats);
const favorites = chats.filter(s => filterIsFavorite(s));
chats = chats.filter(s => !filterIsFavorite(s));
tempChats = this.addRoomsGroup(favorites, FAVORITES_HEADER, tempChats);
}

// type
Expand All @@ -420,18 +425,14 @@ class RoomsListView extends React.Component {
const channels = chats.filter(s => s.t === 'c' && !s.prid);
const privateGroup = chats.filter(s => s.t === 'p' && !s.prid);
const direct = chats.filter(s => s.t === 'd' && !s.prid);
tempChats = this.addRoomsGroup(discussions, DISCUSSIONS_HEADER, tempChats);
tempChats = this.addRoomsGroup(channels, CHANNELS_HEADER, tempChats);
tempChats = this.addRoomsGroup(privateGroup, GROUPS_HEADER, tempChats);
tempChats = this.addRoomsGroup(direct, DM_HEADER, tempChats);
} else if (showUnread) {
chats = chats.filter(s => (!s.unread && !s.alert) || s.hideUnreadStatus);
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
} else if (showFavorites) {
chats = chats.filter(s => !s.f);
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
tempChats = this.addRoomsGroup(discussions, DISCUSSIONS_HEADER, tempChats);
tempChats = this.addRoomsGroup(channels, CHANNELS_HEADER, tempChats);
tempChats = this.addRoomsGroup(privateGroup, GROUPS_HEADER, tempChats);
tempChats = this.addRoomsGroup(direct, DM_HEADER, tempChats);
} else if (showUnread || showFavorites) {
tempChats = this.addRoomsGroup(chats, CHATS_HEADER, tempChats);
} else {
tempChats = chats;
tempChats = chats;
}

this.internalSetState({
Expand Down