2018-04-05 19:13:32 +00:00
|
|
|
import createReducer from 'utils/createReducer';
|
2017-05-26 06:20:00 +00:00
|
|
|
import * as actions from './actions';
|
|
|
|
|
2018-04-25 03:36:27 +00:00
|
|
|
const initialState = {
|
2017-05-26 06:20:00 +00:00
|
|
|
show: false,
|
2018-04-25 03:36:27 +00:00
|
|
|
results: []
|
|
|
|
};
|
2017-05-26 06:20:00 +00:00
|
|
|
|
|
|
|
export const getSearch = state => state.search;
|
|
|
|
|
2018-04-25 03:36:27 +00:00
|
|
|
export default createReducer(initialState, {
|
|
|
|
[actions.socket.SEARCH](state, { results }) {
|
2018-05-25 21:54:36 +00:00
|
|
|
state.results = results || [];
|
2017-05-26 06:20:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
[actions.TOGGLE_SEARCH](state) {
|
2018-04-25 03:36:27 +00:00
|
|
|
state.show = !state.show;
|
2017-05-26 06:20:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-06-15 08:58:51 +00:00
|
|
|
export function searchMessages(network, channel, phrase) {
|
2017-05-26 06:20:00 +00:00
|
|
|
return {
|
|
|
|
type: actions.SEARCH_MESSAGES,
|
2020-06-15 08:58:51 +00:00
|
|
|
network,
|
2017-05-26 06:20:00 +00:00
|
|
|
channel,
|
|
|
|
phrase,
|
|
|
|
socket: {
|
|
|
|
type: 'search',
|
2020-06-15 08:58:51 +00:00
|
|
|
data: { network, channel, phrase }
|
2017-05-26 06:20:00 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toggleSearch() {
|
|
|
|
return {
|
|
|
|
type: actions.TOGGLE_SEARCH
|
|
|
|
};
|
|
|
|
}
|