Add channel joining UI, closes #37
This commit is contained in:
parent
f25594e962
commit
24b26aa85f
20 changed files with 1131 additions and 177 deletions
|
@ -6,6 +6,8 @@ export const KICK = 'KICK';
|
|||
export const PART = 'PART';
|
||||
export const SET_TOPIC = 'SET_TOPIC';
|
||||
|
||||
export const CHANNEL_SEARCH = 'CHANNEL_SEARCH';
|
||||
|
||||
export const INPUT_HISTORY_ADD = 'INPUT_HISTORY_ADD';
|
||||
export const INPUT_HISTORY_DECREMENT = 'INPUT_HISTORY_DECREMENT';
|
||||
export const INPUT_HISTORY_INCREMENT = 'INPUT_HISTORY_INCREMENT';
|
||||
|
@ -64,6 +66,7 @@ export const socket = createSocketActions([
|
|||
'cert_fail',
|
||||
'cert_success',
|
||||
'channels',
|
||||
'channel_search',
|
||||
'connection_update',
|
||||
'join',
|
||||
'message',
|
||||
|
|
41
client/js/state/channelSearch.js
Normal file
41
client/js/state/channelSearch.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
import createReducer from 'utils/createReducer';
|
||||
import * as actions from 'state/actions';
|
||||
|
||||
const initialState = {
|
||||
results: [],
|
||||
end: false
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
[actions.socket.CHANNEL_SEARCH](state, { results, start }) {
|
||||
if (results) {
|
||||
state.end = false;
|
||||
|
||||
if (start > 0) {
|
||||
state.results.push(...results);
|
||||
} else {
|
||||
state.results = results;
|
||||
}
|
||||
} else {
|
||||
state.end = true;
|
||||
}
|
||||
},
|
||||
|
||||
[actions.OPEN_MODAL](state, { name }) {
|
||||
if (name === 'channel') {
|
||||
return initialState;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export function searchChannels(server, q, start) {
|
||||
return {
|
||||
type: actions.CHANNEL_SEARCH,
|
||||
server,
|
||||
q,
|
||||
socket: {
|
||||
type: 'channel_search',
|
||||
data: { server, q, start }
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import { combineReducers } from 'redux';
|
||||
import app from './app';
|
||||
import channels from './channels';
|
||||
import channelSearch from './channelSearch';
|
||||
import input from './input';
|
||||
import messages from './messages';
|
||||
import modals from './modals';
|
||||
|
@ -19,6 +20,7 @@ export default function createReducer(router) {
|
|||
router,
|
||||
app,
|
||||
channels,
|
||||
channelSearch,
|
||||
input,
|
||||
messages,
|
||||
modals,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue