Copilot commented on code in PR #725:
URL: https://github.com/apache/shenyu-dashboard/pull/725#discussion_r4311497235
##########
src/models/instance.js:
##########
@@ -29,12 +41,16 @@ export default {
total: 0,
pieData: [],
lineList: [],
Review Comment:
`state` initializes `lineList`, but the reducer/effects use `lineData` (see
`saveInstancesAnalysis`). This creates two separate fields (`lineList` and
`lineData`) and can leave old chart data uncleared or charts reading from the
wrong key depending on the UI code. Rename `lineList` to `lineData` in initial
state (or update reducer/effects to consistently use `lineList`) so there’s a
single canonical field.
##########
src/models/instance.js:
##########
@@ -50,15 +66,31 @@ export default {
});
}
},
- *fetchAnalysis(params, { call, put }) {
+ *fetchAnalysis(params, { call, put, select }) {
const { payload } = params;
+ const { namespaceId } = payload;
+ const shownNamespaceId = yield select(
+ ({ instance }) => instance.analysisNamespaceId,
+ );
+ if (shownNamespaceId !== namespaceId) {
+ // Don't keep showing the charts of the previous namespace while this
+ // one loads, or if it fails.
+ yield put({
+ type: "saveInstancesAnalysis",
+ payload: { namespaceId, pieData: [], lineData: [] },
+ });
+ }
Review Comment:
`fetchAnalysis` clears charts *before* checking whether the request is stale
(the stale check happens after the API call). If a stale `fetchAnalysis` action
for an older namespace is processed while the user is already on a different
namespace, this can incorrectly clear the current namespace’s charts. Consider
performing an early stale-action guard (compare `namespaceId` to
`global.currentNamespaceId` via `select`) before the clearing `put`, and return
early when it doesn’t match.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]