Skip to content

Commit

Permalink
Merge pull request #7138 from TheThingsNetwork/fix/application-events…
Browse files Browse the repository at this point in the history
…-store

Fix mutated state in application reducer
  • Loading branch information
kschiffer authored Jun 13, 2024
2 parents dbffcac + b51814a commit b68c7e9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ For details about compatibility between different releases, see the **Commitment

### Fixed

- Fix potential issue with application event stream stopping after showing initial events.

### Security

## [3.30.2] - unreleased
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"react-toastify": "^9.1.3",
"react-virtualized-auto-sizer": "^1.0.24",
"react-window": "^1.8.10",
"redux": "^4.2.1",
"redux": "^5.0.1",
"redux-actions": "^2.6.5",
"redux-logic": "^5.0.1",
"reselect": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion pkg/webui/console/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const store = configureStore({
ignoredActionPaths: ['meta._resolve', 'meta._reject'],
},
}).concat(middlewares),
enhancert: getDefaultEnhancers => getDefaultEnhancers().concat(enhancers),
enhancer: getDefaultEnhancers => getDefaultEnhancers().concat(enhancers),
devTools: dev && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__,
})

Expand Down
10 changes: 9 additions & 1 deletion pkg/webui/console/store/reducers/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const devices = (state = defaultState, { type, payload, event }) => {
const id = getCombinedDeviceId(event.identifiers[0].device_ids)
const receivedAt = getByPath(event, 'data.received_at')
if (receivedAt) {
const currentEndDevice = state.entities[id]
const currentEndDevice = { ...state.entities[id] }
if (currentEndDevice) {
// Only update if the event was actually more recent than the current value.
if (
Expand All @@ -218,6 +218,14 @@ const devices = (state = defaultState, { type, payload, event }) => {
) {
currentEndDevice.last_seen_at = receivedAt
}

return {
...state,
entities: {
...state.entities,
[id]: currentEndDevice,
},
}
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@
core-js "^2.6.12"
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.0.0", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.6", "@babel/runtime@^7.17.8", "@babel/runtime@^7.18.3", "@babel/runtime@^7.23.9", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.6", "@babel/runtime@^7.17.8", "@babel/runtime@^7.18.3", "@babel/runtime@^7.23.9", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7":
version "7.23.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.9.tgz#47791a15e4603bb5f905bc0753801cf21d6345f7"
integrity sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==
Expand Down Expand Up @@ -10621,13 +10621,6 @@ redux-thunk@^3.1.0:
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-3.1.0.tgz#94aa6e04977c30e14e892eae84978c1af6058ff3"
integrity sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==

redux@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.2.1.tgz#c08f4306826c49b5e9dc901dee0452ea8fce6197"
integrity sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==
dependencies:
"@babel/runtime" "^7.9.2"

redux@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/redux/-/redux-5.0.1.tgz#97fa26881ce5746500125585d5642c77b6e9447b"
Expand Down

0 comments on commit b68c7e9

Please sign in to comment.