insomnia/app/redux/modules/requests.js
Gregory Schier e9d64ebb23 Workspaces (#7)
* Got a hacky workspace implementation running

* Removed some hax with reducer composition

* Moved some more around

* Moved files back out

* Started on entities reducer

* Split up some components

* Moved nested modules back out of workspaces

* Started on new Sidebar tree stuff

* Better store stuff

* Some more tweaks

* Removed workspace update action

* Re-implemented filtering in the Sidbare

* Switch to get the newest response
2016-04-26 00:29:24 -07:00

51 lines
1016 B
JavaScript

import * as network from '../../lib/network'
import {loadStart, loadStop} from './global'
import {show} from './modals'
import {MODAL_REQUEST_RENAME} from '../../lib/constants'
export const REQUEST_CHANGE_FILTER = 'requests/filter';
const initialState = {
filter: ''
};
// ~~~~~~~~ //
// REDUCERS //
// ~~~~~~~~ //
export default function (state = initialState, action) {
switch (action.type) {
case REQUEST_CHANGE_FILTER:
const filter = action.filter;
return Object.assign({}, state, {filter});
default:
return state;
}
}
// ~~~~~~~ //
// ACTIONS //
// ~~~~~~~ //
export function changeFilter (filter) {
return {type: REQUEST_CHANGE_FILTER, filter};
}
export function send (request) {
return dispatch => {
dispatch(loadStart());
network.send(request, () => {
dispatch(loadStop());
});
}
}
export function showUpdateNamePrompt (request) {
const defaultValue = request.name;
return show(MODAL_REQUEST_RENAME, {defaultValue, request});
}