Keep TabList sorted
This commit is contained in:
parent
7160db9614
commit
6624a97ce7
File diff suppressed because one or more lines are too long
@ -2,17 +2,17 @@ import { connect } from 'react-redux';
|
|||||||
import { createStructuredSelector } from 'reselect';
|
import { createStructuredSelector } from 'reselect';
|
||||||
import App from 'components/App';
|
import App from 'components/App';
|
||||||
import { getConnected } from 'state/app';
|
import { getConnected } from 'state/app';
|
||||||
import { getChannels } from 'state/channels';
|
import { getSortedChannels } from 'state/channels';
|
||||||
import { getPrivateChats } from 'state/privateChats';
|
import { getSortedPrivateChats } from 'state/privateChats';
|
||||||
import { getServers } from 'state/servers';
|
import { getServers } from 'state/servers';
|
||||||
import { getSelectedTab, select } from 'state/tab';
|
import { getSelectedTab, select } from 'state/tab';
|
||||||
import { getShowTabList, hideMenu } from 'state/ui';
|
import { getShowTabList, hideMenu } from 'state/ui';
|
||||||
import { push } from 'util/router';
|
import { push } from 'util/router';
|
||||||
|
|
||||||
const mapState = createStructuredSelector({
|
const mapState = createStructuredSelector({
|
||||||
channels: getChannels,
|
channels: getSortedChannels,
|
||||||
connected: getConnected,
|
connected: getConnected,
|
||||||
privateChats: getPrivateChats,
|
privateChats: getSortedPrivateChats,
|
||||||
servers: getServers,
|
servers: getServers,
|
||||||
showTabList: getShowTabList,
|
showTabList: getShowTabList,
|
||||||
tab: getSelectedTab
|
tab: getSelectedTab
|
||||||
|
@ -78,6 +78,17 @@ function compareUsers(a, b) {
|
|||||||
|
|
||||||
export const getChannels = state => state.channels;
|
export const getChannels = state => state.channels;
|
||||||
|
|
||||||
|
const key = (v, k) => k.toLowerCase();
|
||||||
|
|
||||||
|
export const getSortedChannels = createSelector(
|
||||||
|
getChannels,
|
||||||
|
channels => channels.withMutations(c =>
|
||||||
|
c.forEach((server, address) =>
|
||||||
|
c.update(address, chans => chans.sortBy(key))
|
||||||
|
)
|
||||||
|
).sortBy(key)
|
||||||
|
);
|
||||||
|
|
||||||
export const getSelectedChannel = createSelector(
|
export const getSelectedChannel = createSelector(
|
||||||
getSelectedTab,
|
getSelectedTab,
|
||||||
getChannels,
|
getChannels,
|
||||||
|
@ -1,10 +1,22 @@
|
|||||||
import { Set, Map } from 'immutable';
|
import { Set, Map } from 'immutable';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
import createReducer from 'util/createReducer';
|
import createReducer from 'util/createReducer';
|
||||||
import { updateSelection } from './tab';
|
import { updateSelection } from './tab';
|
||||||
import * as actions from './actions';
|
import * as actions from './actions';
|
||||||
|
|
||||||
export const getPrivateChats = state => state.privateChats;
|
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) {
|
function open(state, server, nick) {
|
||||||
return state.update(server, Set(), chats => chats.add(nick));
|
return state.update(server, Set(), chats => chats.add(nick));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user