From 246b00e2bf7f0db64219a88c67cdfb5344b711a8 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 2 Sep 2025 09:48:54 -0500 Subject: [PATCH] Convert backend to use jsonb fields. --- frontend/src/api.js | 4 ---- frontend/src/components/forms/M3UFilter.jsx | 3 +-- frontend/src/components/forms/M3UGroupFilter.jsx | 10 +++------- frontend/src/pages/Guide.jsx | 8 ++++---- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index 982eae78..aeedf0ae 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -761,10 +761,6 @@ export default class API { } static async addPlaylist(values) { - if (values.custom_properties) { - values.custom_properties = JSON.stringify(values.custom_properties); - } - try { let body = null; if (values.file) { diff --git a/frontend/src/components/forms/M3UFilter.jsx b/frontend/src/components/forms/M3UFilter.jsx index 75e76013..dcb3323f 100644 --- a/frontend/src/components/forms/M3UFilter.jsx +++ b/frontend/src/components/forms/M3UFilter.jsx @@ -38,8 +38,7 @@ const M3UFilter = ({ filter = null, m3u, isOpen, onClose }) => { filter_type: filter.filter_type, regex_pattern: filter.regex_pattern, exclude: filter.exclude, - case_sensitive: - JSON.parse(filter.custom_properties || '{}').case_sensitive ?? true, + case_sensitive: (filter.custom_properties || {}).case_sensitive ?? true, }); } else { form.reset(); diff --git a/frontend/src/components/forms/M3UGroupFilter.jsx b/frontend/src/components/forms/M3UGroupFilter.jsx index 7d3d9b56..469b87e3 100644 --- a/frontend/src/components/forms/M3UGroupFilter.jsx +++ b/frontend/src/components/forms/M3UGroupFilter.jsx @@ -101,22 +101,18 @@ const M3UGroupFilter = ({ playlist = null, isOpen, onClose }) => { const submit = async () => { setIsLoading(true); try { - // Prepare groupStates for API: custom_properties must be stringified + // Prepare groupStates for API // Send ALL group states like the original code did, don't filter by enabled changes const groupSettings = groupStates.map((state) => ({ ...state, - custom_properties: state.custom_properties - ? JSON.stringify(state.custom_properties) - : undefined, + custom_properties: state.custom_properties || undefined, })); const categorySettings = movieCategoryStates .concat(seriesCategoryStates) .map((state) => ({ ...state, - custom_properties: state.custom_properties - ? JSON.stringify(state.custom_properties) - : undefined, + custom_properties: state.custom_properties || undefined, })) .filter((state) => state.enabled !== state.original_enabled); diff --git a/frontend/src/pages/Guide.jsx b/frontend/src/pages/Guide.jsx index af959fb7..a12bc37a 100644 --- a/frontend/src/pages/Guide.jsx +++ b/frontend/src/pages/Guide.jsx @@ -288,9 +288,9 @@ export default function TVChannelGuide({ startDate, endDate }) { channel: `${channel.id}`, start_time: program.start_time, end_time: program.end_time, - custom_properties: JSON.stringify({ + custom_properties: { program, - }), + }, }); notifications.show({ title: 'Recording scheduled' }); }; @@ -353,7 +353,7 @@ export default function TVChannelGuide({ startDate, endDate }) { // Check if this program has a recording const programRecording = recordings.find((recording) => { if (recording.custom_properties) { - const customProps = JSON.parse(recording.custom_properties); + const customProps = recording.custom_properties || {}; if (customProps.program && customProps.program.id == program.id) { return true; } @@ -513,7 +513,7 @@ export default function TVChannelGuide({ startDate, endDate }) { // Check if we have a recording for this program const recording = recordings.find((recording) => { if (recording.custom_properties) { - const customProps = JSON.parse(recording.custom_properties); + const customProps = recording.custom_properties || {}; if (customProps.program && customProps.program.id == program.id) { return recording; }