mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
41 lines
940 B
TypeScript
41 lines
940 B
TypeScript
import type {FlamegraphFrame} from 'sentry/utils/profiling/flamegraphFrame';
|
|
|
|
type SetProfilesThreadId = {
|
|
payload: number;
|
|
type: 'set thread id';
|
|
};
|
|
|
|
type SetRootNode = {
|
|
payload: FlamegraphFrame | null;
|
|
type: 'set selected root';
|
|
};
|
|
|
|
type FlamegraphProfilesAction = SetProfilesThreadId | SetRootNode;
|
|
|
|
export type FlamegraphProfiles = {
|
|
selectedRoot: FlamegraphFrame | null;
|
|
threadId: number | null;
|
|
};
|
|
|
|
export function flamegraphProfilesReducer(
|
|
state: FlamegraphProfiles,
|
|
action: FlamegraphProfilesAction
|
|
): FlamegraphProfiles {
|
|
switch (action.type) {
|
|
case 'set selected root': {
|
|
return {...state, selectedRoot: action.payload};
|
|
}
|
|
case 'set thread id': {
|
|
// When the profile index changes, we want to drop the selected and hovered nodes
|
|
return {
|
|
...state,
|
|
selectedRoot: null,
|
|
threadId: action.payload,
|
|
};
|
|
}
|
|
default: {
|
|
return state;
|
|
}
|
|
}
|
|
}
|