Skip to content

Commit e59d2dd

Browse files
authored
Use type check instead of cast (#6041)
Under some infrequent circumstances, `audioWidget.value` is not a string. Presumably if a workflow is loaded with a saved file choice that does not exist and the value is set to undefined instead. Instead of a cast, a proper type guard is used and the widget is not updated if the new value is not a string. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6041-Use-type-check-instead-of-cast-28b6d73d365081249353f4f905769f89) by [Unito](https://www.unito.io)
1 parent d54923f commit e59d2dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/extensions/core/uploadAudio.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ app.registerExtension({
178178
audioUIWidget.options.canvasOnly = true
179179

180180
const onAudioWidgetUpdate = () => {
181+
if (typeof audioWidget.value !== 'string') return
181182
audioUIWidget.element.src = api.apiURL(
182-
getResourceURL(...splitFilePath(audioWidget.value as string))
183+
getResourceURL(...splitFilePath(audioWidget.value))
183184
)
184185
}
185186
// Initially load default audio file to audioUIWidget.

0 commit comments

Comments
 (0)