Skip to content

Commit

Permalink
Fix issues related to item names being unnecessarily rendered (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboberg authored Feb 13, 2025
1 parent bc13514 commit 810f59e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
6 changes: 3 additions & 3 deletions api/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ class Items {
/*
Use caching if it's safe to do so
The cache key must depend on the local this.#props.State revision
The cache key must depend on the local state revision
in order to not get out of date, and that will only
get updated if the this.#props.Client is listening for the
'this.#props.State.change' event
'state.change' event
*/
if (
this.#props.Events.hasRemoteHandler('this.#props.State.change') &&
this.#props.Events.hasRemoteHandler('state.change') &&
this.#props.State.getLocalRevision() !== 0
) {
return this.#cache.cache(`${id}::${this.#props.State.getLocalRevision()}`, () => {
Expand Down
6 changes: 3 additions & 3 deletions api/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ class Types {
/*
Use caching if it's safe to do so
The cache key must depend on the local this.#props.State revision
The cache key must depend on the local state revision
in order to not get out of date, and that will only
get updated if the client is listening for the
'this.#props.State.change' event
'state.change' event
*/
if (
this.#props.Events.hasRemoteHandler('this.#props.State.change') &&
this.#props.Events.hasRemoteHandler('state.change') &&
this.#props.State.getLocalRevision() !== 0
) {
return this.#cache.cache(`${id}::${this.#props.State.getLocalRevision()}`, async () => this.getTypeUncached(id))
Expand Down
12 changes: 12 additions & 0 deletions plugins/inspector/app/components/VariableStringInput/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,19 @@ function getCompletion (str, completions) {
return matches[0]
}

/**
* Get all possible paths to
* leaves from an object in
* dot-notation
*
* @param { Object } obj
* @returns { String[] }
*/
function getPathsFromObject (obj) {
if (!obj || typeof obj !== 'object') {
return []
}

const out = []
for (const key of Object.keys(obj)) {
out.push(key)
Expand Down
11 changes: 10 additions & 1 deletion plugins/rundown/app/components/RundownItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,17 @@ export function RundownItem ({ index, item }) {
const [typeProperties, setTypeProperties] = React.useState([])

const [name] = useAsyncValue(() => {
/*
Make sure to check if there
really is a variable to render
as that operation is rather expensive
*/
if (!bridge.variables.stringContainsVariable(item?.data?.name)) {
return item?.data?.name
}

return bridge.items.renderValue(item.id, 'data.name')
}, [item])
}, [item?.data?.name])

const displaySettings = shared?.plugins?.['bridge-plugin-rundown']?.settings?.display

Expand Down

0 comments on commit 810f59e

Please sign in to comment.