MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / buildOverridePayload

Function buildOverridePayload

frontend/src/utils/forms/ChannelUtils.js:148–170  ·  view source on GitHub ↗
(channel, formattedValues)

Source from the content-addressed store, hash-verified

146// provider values. Matching fields become null (clear); diverging
147// fields carry the form value.
148export const buildOverridePayload = (channel, formattedValues) => {
149 if (!channel) return undefined;
150 const payload = {};
151 let anyOverride = false;
152
153 for (const field of OVERRIDABLE_FIELDS) {
154 const formValue = normalizeFieldValue(field, formattedValues[field]);
155 const providerValue = normalizeFieldValue(field, channel[field]);
156 if (formValue === null && providerValue === null) continue;
157 if (formValue !== providerValue) {
158 payload[field] = formValue;
159 if (formValue !== null) anyOverride = true;
160 } else {
161 payload[field] = null;
162 }
163 }
164
165 if (!anyOverride) {
166 // Every field matches provider; explicit null deletes the row.
167 return null;
168 }
169 return payload;
170};
171
172// Prefer the backend-resolved effective_* so the form loads with the
173// overridden value; fall back to the raw field otherwise.

Callers 2

handleEpgUpdateFunction · 0.85

Calls 1

normalizeFieldValueFunction · 0.85

Tested by

no test coverage detected