Skip to content

Commit

Permalink
Store templateData as a string
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Apr 26, 2024
1 parent ef42196 commit 6276242
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions plugins/caspar/app/views/InspectorTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/caspar/lib/AMCP.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6276242

Please sign in to comment.