Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-22.2: ui: revert TransactionInsightDetailsCachedState.cachedData object #95063

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const StatementInsightDetails: React.FC<
const executionID = getMatchParamByName(match, idAttr);

useEffect(() => {
if (insightEventDetails == null) {
if (!insightEventDetails) {
refreshStatementInsights();
}
}, [insightEventDetails, refreshStatementInsights]);
Expand All @@ -124,7 +124,7 @@ export const StatementInsightDetails: React.FC<
</h3>
<div>
<Loading
loading={insightEventDetails == null}
loading={!insightEventDetails}
page={"Transaction Insight details"}
error={insightError}
renderError={() => InsightsError()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const TransactionInsightDetails: React.FC<
</div>
<section>
<Loading
loading={insightEventDetails == null}
loading={!insightDetails}
page={"Transaction Insight details"}
error={insightError}
renderError={() => InsightsError()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ const txnInitialState: TransactionInsightDetailsState = {
};

export type TransactionInsightDetailsCachedState = {
cachedData: Map<string, TransactionInsightDetailsState>;
cachedData: {
[id: string]: TransactionInsightDetailsState;
};
};

const initialState: TransactionInsightDetailsCachedState = {
cachedData: new Map(),
cachedData: {},
};

const transactionInsightDetailsSlice = createSlice({
Expand All @@ -47,22 +49,25 @@ const transactionInsightDetailsSlice = createSlice({
state,
action: PayloadAction<TransactionInsightEventDetailsResponse>,
) => {
state.cachedData.set(action.payload.executionID, {
data: action.payload,
valid: true,
lastError: null,
lastUpdated: moment.utc(),
});
if (action?.payload?.executionID) {
state.cachedData[action.payload.executionID] = {
data: action.payload,
valid: true,
lastError: null,
lastUpdated: moment.utc(),
};
}
},
failed: (state, action: PayloadAction<ErrorWithKey>) => {
const txnInsight =
state.cachedData.get(action.payload.key) ?? txnInitialState;
txnInsight.valid = false;
txnInsight.lastError = action.payload.err;
state.cachedData.set(action.payload.key, txnInsight);
state.cachedData[action.payload.key] = {
data: null,
valid: false,
lastError: action?.payload?.err,
lastUpdated: null,
};
},
invalidated: (state, action: PayloadAction<{ key: string }>) => {
state.cachedData.delete(action.payload.key);
delete state.cachedData[action.payload.key];
},
refresh: (
_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const selectTransactionInsightDetailsState = createSelector(
(state: AppState) => state.adminUI.transactionInsightDetails.cachedData,
selectID,
(cachedTxnInsightDetails, execId) => {
return cachedTxnInsightDetails.get(execId);
return cachedTxnInsightDetails[execId];
},
);

export const selectTransactionInsightDetails = createSelector(
selectTransactionInsightDetailsState,
state => state.data,
state => state?.data,
);

export const selectTransactionInsightDetailsError = createSelector(
selectTransactionInsightDetailsState,
state => state.lastError,
state => state?.lastError,
);