From 8ca91bd897b2bf7429f757226dcb85c2266cf7ca Mon Sep 17 00:00:00 2001 From: dekzter Date: Wed, 19 Mar 2025 07:15:31 -0400 Subject: [PATCH] fixed match epg, centralized to api --- frontend/src/api.js | 13 ++++++++++++ .../src/components/tables/ChannelsTable.jsx | 20 ++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index 8a3cd97e..60403bd0 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -856,4 +856,17 @@ export default class API { const retval = await response.json(); return retval; } + + static async matchEpg() { + const response = await fetch(`${host}/api/channels/channels/match-epg/`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${await API.getAuthToken()}`, + }, + }); + + const retval = await response.json(); + return retval; + } } diff --git a/frontend/src/components/tables/ChannelsTable.jsx b/frontend/src/components/tables/ChannelsTable.jsx index c1e2889e..e570463f 100644 --- a/frontend/src/components/tables/ChannelsTable.jsx +++ b/frontend/src/components/tables/ChannelsTable.jsx @@ -376,22 +376,14 @@ const ChannelsTable = ({}) => { const matchEpg = async () => { try { // Hit our new endpoint that triggers the fuzzy matching Celery task - const resp = await fetch('/api/channels/channels/match-epg/', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${await API.getAuthToken()}`, - }, - }); + await API.matchEpg(); - if (resp.ok) { - showAlert('EPG matching task started!'); - } else { - const text = await resp.text(); - showAlert(`Failed to start EPG matching: ${text}`); - } + notifications.show({ + title: 'EPG matching task started!', + // style: { width: '200px', left: '200px' }, + }); } catch (err) { - showAlert(`Error: ${err.message}`); + notifications.show(`Error: ${err.message}`); } };