mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 08:25:54 +01:00
Ability to cancel an import lookup/search at any point. Ability to move artist path from Artist Edit or bulk move from Mass Editor. Trigger manual import for Artist path from Artist Detail page. Pulled from Sonarr
27 lines
582 B
JavaScript
27 lines
582 B
JavaScript
const thunks = {};
|
|
|
|
function identity(payload) {
|
|
return payload;
|
|
}
|
|
|
|
export function createThunk(type, identityFunction = identity) {
|
|
return function(payload = {}) {
|
|
return function(dispatch, getState) {
|
|
const thunk = thunks[type];
|
|
|
|
if (thunk) {
|
|
return thunk(getState, identityFunction(payload), dispatch);
|
|
}
|
|
|
|
throw Error(`Thunk handler has not been registered for ${type}`);
|
|
};
|
|
};
|
|
}
|
|
|
|
export function handleThunks(handlers) {
|
|
const types = Object.keys(handlers);
|
|
|
|
types.forEach((type) => {
|
|
thunks[type] = handlers[type];
|
|
});
|
|
}
|