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

Method updateEPG

frontend/src/api.js:1630–1690  ·  view source on GitHub ↗
(values, isToggle = false)

Source from the content-addressed store, hash-verified

1628 }
1629
1630 static async updateEPG(values, isToggle = false) {
1631 // Validate that values is an object
1632 if (!values || typeof values !== 'object') {
1633 console.error('updateEPG called with invalid values:', values);
1634 return;
1635 }
1636
1637 const { id, ...payload } = values;
1638
1639 // Validate that we have an ID and payload is an object
1640 if (!id || typeof payload !== 'object') {
1641 console.error('updateEPG: invalid id or payload', { id, payload });
1642 return;
1643 }
1644
1645 try {
1646 // If this is just toggling the active state, make a simpler request
1647 if (
1648 isToggle &&
1649 'is_active' in payload &&
1650 Object.keys(payload).length === 1
1651 ) {
1652 const response = await request(`${host}/api/epg/sources/${id}/`, {
1653 method: 'PATCH',
1654 body: { is_active: payload.is_active },
1655 });
1656
1657 useEPGsStore.getState().updateEPG(response);
1658 return response;
1659 }
1660
1661 // Original implementation for full updates
1662 let body = null;
1663 if (payload.files) {
1664 body = new FormData();
1665 for (const prop in payload) {
1666 if (prop == 'url') {
1667 continue;
1668 }
1669 body.append(prop, payload[prop]);
1670 }
1671 } else {
1672 delete payload.file;
1673 if (!payload.url) {
1674 delete payload.url;
1675 }
1676 body = payload;
1677 }
1678
1679 const response = await request(`${host}/api/epg/sources/${id}/`, {
1680 method: 'PATCH',
1681 body,
1682 });
1683
1684 useEPGsStore.getState().updateEPG(response);
1685
1686 return response;
1687 } catch (e) {

Callers 4

toggleActiveFunction · 0.80
updateEPGFunction · 0.80
epgs.test.jsxFile · 0.80

Calls 3

requestFunction · 0.85
errorNotificationFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected