Skip to content
Closed
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
15 changes: 9 additions & 6 deletions code/core/src/actions/containers/ActionLogger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ export default function ActionLogger({ active, api }: ActionLoggerProps) {

const addAction = useCallback((action: ActionDisplay) => {
setActions((prevActions) => {
const newActions = [...prevActions];
const previous = newActions.length && newActions[newActions.length - 1];
const limit = Math.max(0, Number(action.options?.limit) || 0);
const previous = prevActions.length ? prevActions[prevActions.length - 1] : null;

if (previous && safeDeepEqual(previous.data, action.data)) {
previous.count++;
const updated = [...prevActions];
updated[updated.length - 1] = { ...previous, count: previous.count + 1 };
return limit > 0 ? updated.slice(-limit) : updated;
} else {
action.count = 1;
newActions.push(action);
const newAction = { ...action, count: 1 };
const newActions = [...prevActions, newAction];
return limit > 0 ? newActions.slice(-limit) : newActions;
}
return newActions.slice(0, action.options.limit);
});
}, []);

Expand Down