Skip to content

Commit

Permalink
do not crash if a widget tries to update widget on non-existent view
Browse files Browse the repository at this point in the history
- closes #327
  • Loading branch information
foxriver76 committed Jan 29, 2024
1 parent 4d40ad8 commit 021d3a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ E.g., if it was used in a menu and the menu is red, the circle would be red.
### **WORK IN PROGRESS**
* (foxriver76) fixed resizing issue for relative widgets
* (foxriver76) do not crash when using visibility "only for groups"
* (foxriver76) do not crash if a widget tries to update widget on non-existent view

### 2.9.24 (2024-01-24)
* (foxriver76) Image 8 widget ported to react
Expand Down
12 changes: 12 additions & 0 deletions src/src/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@ const reducer = createReducer(
})
.addCase(updateWidget, (state, action) => {
const { viewId, widgetId, data } = action.payload;

if (!(viewId in state.visProject)) {
console.error(`Cannot update widget "${widgetId}". The view "${viewId}" does not exist in the project.`);
return;
}

state.visProject[viewId].widgets[widgetId] = data;
})
.addCase(updateGroupWidget, (state, action) => {
const { viewId, widgetId, data } = action.payload;

if (!(viewId in state.visProject)) {
console.error(`Cannot update group widget "${widgetId}". The view "${viewId}" does not exist in the project.`);
return;
}

state.visProject[viewId].widgets[widgetId] = data;
})
.addCase(updateActiveUser, (state, action) => {
Expand Down

0 comments on commit 021d3a2

Please sign in to comment.