Skip to content
Snippets Groups Projects
Unverified Commit ea3b0280 authored by Ibe Dwi's avatar Ibe Dwi Committed by GitHub
Browse files

Fix negative value on loading dashboard title (#35633)

* fix: duplicated loadingIds on pending action

* chore: rename unit test name
parent e48a7ce9
No related branches found
No related tags found
No related merge requests found
......@@ -388,7 +388,9 @@ const loadingDashCards = handleActions(
},
[FETCH_CARD_DATA_PENDING]: {
next: (state, { payload: { dashcard_id } }) => {
const loadingIds = state.loadingIds.concat(dashcard_id);
const loadingIds = !state.loadingIds.includes(dashcard_id)
? state.loadingIds.concat(dashcard_id)
: state.loadingIds;
return {
...state,
loadingIds,
......
......@@ -8,6 +8,7 @@ import {
SET_DASHBOARD_ATTRIBUTES,
FETCH_DASHBOARD_CARD_DATA,
FETCH_CARD_DATA,
FETCH_CARD_DATA_PENDING,
} from "./actions";
describe("dashboard reducers", () => {
......@@ -346,5 +347,26 @@ describe("dashboard reducers", () => {
dashcardData: { 3: { 1: {} } },
});
});
it("should not have duplicated elements in loadingIds on pending (metabase#33692, metabase#34767)", () => {
const result = reducer(
{
...initState,
loadingDashCards: {
loadingIds: [3],
loadingStatus: "running",
startTime: 100,
},
},
{
type: FETCH_CARD_DATA_PENDING,
payload: {
dashcard_id: 3,
card_id: 1,
},
},
);
expect(result.loadingDashCards.loadingIds).toEqual([3]);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment