| 52 | export default optionsSlice.reducer; |
| 53 | |
| 54 | export async function pureSendUpdate(option: Option, value, dispatch) { |
| 55 | try { |
| 56 | const response = await fetchApi.put("/options", { |
| 57 | [option]: value, |
| 58 | }); |
| 59 | if (response.status === 200) { |
| 60 | dispatch(optionsEditorActions.updateSuccess({ option })); |
| 61 | } else { |
| 62 | throw await response.text(); |
| 63 | } |
| 64 | } catch (error) { |
| 65 | dispatch( |
| 66 | optionsEditorActions.updateError({ |
| 67 | option, |
| 68 | error: error.toString(), |
| 69 | }), |
| 70 | ); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | const sendUpdate = pureSendUpdate; // _.throttle(pureSendUpdate, 500, {leading: true, trailing: true}) |
| 75 | |