Keep TabList sorted

This commit is contained in:
Ken-Håvard Lieng 2017-06-29 06:56:05 +02:00
parent 7160db9614
commit 6624a97ce7
4 changed files with 46 additions and 23 deletions

View file

@ -1,10 +1,22 @@
import { Set, Map } from 'immutable';
import { createSelector } from 'reselect';
import createReducer from 'util/createReducer';
import { updateSelection } from './tab';
import * as actions from './actions';
export const getPrivateChats = state => state.privateChats;
const lowerCaseValue = v => v.toLowerCase();
export const getSortedPrivateChats = createSelector(
getPrivateChats,
privateChats => privateChats.withMutations(p =>
p.forEach((server, address) =>
p.update(address, chats => chats.sortBy(lowerCaseValue))
)
)
);
function open(state, server, nick) {
return state.update(server, Set(), chats => chats.add(nick));
}