mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
* New: Release Profiles - UI Updates * New: Release Profiles - API Changes * New: Release Profiles - Test Updates * New: Release Profiles - Backend Updates * New: Interactive Artist Search * New: Change Montiored on Album Details Page * New: Show Duration on Album Details Page * Fixed: Manual Import not working if no albums are Missing * Fixed: Sort search input by sortTitle * Fixed: Queue columnLabel throwing JS error
42 lines
1 KiB
JavaScript
42 lines
1 KiB
JavaScript
import _ from 'lodash';
|
|
import getSectionState from 'Utilities/State/getSectionState';
|
|
|
|
function getProviderState(payload, getState, section) {
|
|
const {
|
|
id,
|
|
...otherPayload
|
|
} = payload;
|
|
|
|
const state = getSectionState(getState(), section, true);
|
|
const pendingChanges = Object.assign({}, state.pendingChanges, otherPayload);
|
|
const pendingFields = state.pendingChanges.fields || {};
|
|
delete pendingChanges.fields;
|
|
|
|
const item = id ? _.find(state.items, { id }) : state.selectedSchema || state.schema || {};
|
|
|
|
if (item.fields) {
|
|
pendingChanges.fields = _.reduce(item.fields, (result, field) => {
|
|
const name = field.name;
|
|
|
|
const value = pendingFields.hasOwnProperty(name) ?
|
|
pendingFields[name] :
|
|
field.value;
|
|
|
|
// Only send the name and value to the server
|
|
result.push({
|
|
name,
|
|
value
|
|
});
|
|
|
|
return result;
|
|
}, []);
|
|
}
|
|
|
|
const result = Object.assign({}, item, pendingChanges);
|
|
|
|
delete result.presets;
|
|
|
|
return result;
|
|
}
|
|
|
|
export default getProviderState;
|