From 6276242112b3639e1aa7ac5ba7df072e50b49379 Mon Sep 17 00:00:00 2001 From: Axel Boberg Date: Fri, 26 Apr 2024 18:26:17 +0200 Subject: [PATCH] Store templateData as a string Signed-off-by: Axel Boberg --- plugins/caspar/app/views/InspectorTemplate.jsx | 9 +++++++-- plugins/caspar/lib/AMCP.js | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/caspar/app/views/InspectorTemplate.jsx b/plugins/caspar/app/views/InspectorTemplate.jsx index 5450d88..c654bb4 100644 --- a/plugins/caspar/app/views/InspectorTemplate.jsx +++ b/plugins/caspar/app/views/InspectorTemplate.jsx @@ -51,11 +51,16 @@ export const InspectorTemplate = () => { function handleSave (newValue) { try { - const parsed = JSON.parse(newValue) + const parsed = JSON.stringify(JSON.parse(newValue)) handleNewValue({ data: { caspar: { - templateData: { $replace: parsed }, + /* + templateData holds the actual data sent in commands + while templateDataString holds prettified data only shown + within the Bridge UI + */ + templateData: parsed, templateDataString: newValue } } diff --git a/plugins/caspar/lib/AMCP.js b/plugins/caspar/lib/AMCP.js index 4277ecf..8c3b833 100644 --- a/plugins/caspar/lib/AMCP.js +++ b/plugins/caspar/lib/AMCP.js @@ -137,7 +137,7 @@ exports.stop = opts => `STOP ${layerString(opts)}` * @param { AMCPOptions } opts * @returns { String } */ -exports.cgAdd = (template, data, playOnLoad = true, opts) => `CG ${layerString(opts)} ADD ${opts.cgLayer ?? 1} "${template}" ${playOnLoad ? 1 : 0} ${JSON.stringify(JSON.stringify(data))}` +exports.cgAdd = (template, data, playOnLoad = true, opts) => `CG ${layerString(opts)} ADD ${opts.cgLayer ?? 1} "${template}" ${playOnLoad ? 1 : 0} ${JSON.stringify(data || '')}` /** * Stop a template @@ -150,11 +150,11 @@ exports.cgStop = opts => `CG ${layerString(opts)} STOP ${opts.cgLayer ?? 1}` /** * Update a template * @see https://github.com/CasparCG/help/wiki/AMCP-Protocol#cg-update - * @param { Object } data + * @param { String } data * @param { AMCPOptions } opts * @returns { String } */ -exports.cgUpdate = (data, opts) => `CG ${layerString(opts)} UPDATE ${opts.cgLayer ?? 1} ${JSON.stringify(JSON.stringify(data))}` +exports.cgUpdate = (data, opts) => `CG ${layerString(opts)} UPDATE ${opts.cgLayer ?? 1} ${JSON.stringify(data || '')}` /** * Change the opacity of a layer