1
0
Fork 0

[react] chore: Guard against undefined settings

This commit is contained in:
joostdecock 2025-04-28 07:06:35 +02:00
parent 5e5edd9d29
commit 663528fa36
17 changed files with 79 additions and 66 deletions

View file

@ -23,6 +23,7 @@ import { HeaderMenu } from '../HeaderMenu.mjs'
* @param {Object} props.update - Helper object for updating the editor state
*/
export const SaveView = ({ config, state, update }) => {
const { settings = {} } = state // Guard against undefined settings
// Hooks
const backend = useBackend()
@ -34,7 +35,7 @@ export const SaveView = ({ config, state, update }) => {
const [saveAs] = useState(false) // FIXME
const addSettingsToNotes = () => {
setNotes(notes + '\n\n#### Settings\n\n```yaml\n' + yaml.dump(state.settings) + '\n````')
setNotes(notes + '\n\n#### Settings\n\n```yaml\n' + yaml.dump(settings) + '\n````')
}
const saveAsNewPattern = async () => {
@ -44,7 +45,7 @@ export const SaveView = ({ config, state, update }) => {
design: state.design,
name,
public: false,
settings: state.settings,
settings,
data: {},
}
if (withNotes) patternData.notes = notes
@ -69,7 +70,7 @@ export const SaveView = ({ config, state, update }) => {
setLoadingStatus([true, 'Saving pattern...'])
const patternData = {
design: state.design,
settings: state.settings,
settings,
name,
public: false,
data: {},