dispatch/client/js/state/search.js

39 lines
718 B
JavaScript
Raw Normal View History

import createReducer from 'utils/createReducer';
import * as actions from './actions';
2018-04-25 03:36:27 +00:00
const initialState = {
show: false,
2018-04-25 03:36:27 +00:00
results: []
};
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 || [];
},
[actions.TOGGLE_SEARCH](state) {
2018-04-25 03:36:27 +00:00
state.show = !state.show;
}
});
2020-06-15 08:58:51 +00:00
export function searchMessages(network, channel, phrase) {
return {
type: actions.SEARCH_MESSAGES,
2020-06-15 08:58:51 +00:00
network,
channel,
phrase,
socket: {
type: 'search',
2020-06-15 08:58:51 +00:00
data: { network, channel, phrase }
}
};
}
export function toggleSearch() {
return {
type: actions.TOGGLE_SEARCH
};
}