inspector: prevent edit errors from breaking sessions; add a notification; reverse the faulty change and prevent history push;
This commit is contained in:
parent
ebacf077c8
commit
67430c8703
3 changed files with 34 additions and 3 deletions
|
|
@ -9,6 +9,8 @@ var {updateWidget, incrementWidget} = require('./data-workers'),
|
|||
UiInspector = require('../ui/ui-inspector'),
|
||||
UiTree = require('../ui/ui-tree'),
|
||||
UiDragResize = require('../ui/ui-dragresize'),
|
||||
notifications = require('../ui/notifications'),
|
||||
locales = require('../locales'),
|
||||
{leftUiSidePanel, rightUiSidePanel} = require('../ui/'),
|
||||
ipc = require('../ipc'),
|
||||
sessionManager
|
||||
|
|
@ -27,17 +29,44 @@ class Editor {
|
|||
this.inspector.on('update', (event)=>{
|
||||
|
||||
var {propName, value} = event,
|
||||
newWidgets = []
|
||||
newWidgets = [],
|
||||
error = false
|
||||
|
||||
for (var w of this.selectedWidgets) {
|
||||
if ((propName === 'label' || propName === 'popupLabel') && value === true) {
|
||||
|
||||
let previousValue = w.props[propName]
|
||||
|
||||
if ((propName === '' || propName === 'popupLabel') && value === true) {
|
||||
w.props[propName] = 'auto'
|
||||
} else {
|
||||
w.props[propName] = value !== '' ? value : deepCopy(defaults[w.props.type][propName].value)
|
||||
}
|
||||
newWidgets.push(updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
|
||||
|
||||
try {
|
||||
|
||||
newWidgets.push(updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1}))
|
||||
|
||||
} catch (e) {
|
||||
|
||||
w.props[propName] = previousValue
|
||||
updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
|
||||
|
||||
notifications.add({
|
||||
class: 'error',
|
||||
message: locales('inspector_error'),
|
||||
duration: 7000
|
||||
})
|
||||
console.error(
|
||||
`Error while setting ${propName} to: ${JSON.stringify(value)}.`,
|
||||
'It\'s probably a bug, please a new bug ticket with these informations (https://github.com/jean-emmanuel/open-stage-control/issues).'
|
||||
)
|
||||
console.error(e)
|
||||
error = true
|
||||
}
|
||||
}
|
||||
|
||||
if (error) return
|
||||
|
||||
this.pushHistory()
|
||||
|
||||
if (newWidgets.length > 1) this.select(newWidgets)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ module.exports = {
|
|||
// inspector
|
||||
inspector_color_confirm: 'Confirm',
|
||||
inspector_color_apply: 'Apply',
|
||||
inspector_error: 'An error just occured, open F12 to read more.',
|
||||
|
||||
// nosleep
|
||||
nosleep: 'Prevent sleep',
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ module.exports = {
|
|||
// inspector
|
||||
inspector_color_confirm: 'Confirmer',
|
||||
inspector_color_apply: 'Appliquer',
|
||||
inspector_error: 'Une erreur vient de survenir, appuyez sur F12 pour en savoir plus.',
|
||||
|
||||
// nosleep
|
||||
nosleep: 'Empêcher la veille',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue