@@ -11,24 +11,8 @@ export function CallStack({ frames, dialogResizerRef }: CallStackProps) {
11
11
const initialDialogHeight = useRef < number > ( NaN )
12
12
const [ isIgnoreListOpen , setIsIgnoreListOpen ] = useState ( false )
13
13
14
- const { visibleFrames, ignoredFrames, ignoreListLength } = useMemo ( ( ) => {
15
- const visible : OriginalStackFrame [ ] = [ ]
16
- const ignored : OriginalStackFrame [ ] = [ ]
17
-
18
- for ( const frame of frames ) {
19
- if ( ! frame . ignored ) {
20
- visible . push ( frame )
21
- }
22
- if ( frame . ignored ) {
23
- ignored . push ( frame )
24
- }
25
- }
26
-
27
- return {
28
- visibleFrames : visible ,
29
- ignoredFrames : ignored ,
30
- ignoreListLength : ignored . length ,
31
- }
14
+ const ignoredFramesTally = useMemo ( ( ) => {
15
+ return frames . reduce ( ( tally , frame ) => tally + ( frame . ignored ? 1 : 0 ) , 0 )
32
16
} , [ frames ] )
33
17
34
18
function onToggleIgnoreList ( ) {
@@ -65,36 +49,22 @@ export function CallStack({ frames, dialogResizerRef }: CallStackProps) {
65
49
{ frames . length }
66
50
</ span >
67
51
</ p >
68
- { ignoreListLength > 0 && (
52
+ { ignoredFramesTally > 0 && (
69
53
< button
70
54
data-expand-ignore-button = { isIgnoreListOpen }
71
55
className = "error-overlay-call-stack-ignored-list-toggle-button"
72
56
onClick = { onToggleIgnoreList }
73
57
>
74
- { `${ isIgnoreListOpen ? 'Hide' : 'Show' } ${ ignoreListLength } ignore-listed frames ` }
58
+ { `${ isIgnoreListOpen ? 'Hide' : 'Show' } ${ ignoredFramesTally } ignore-listed frame(s) ` }
75
59
< ChevronUpDown />
76
60
</ button >
77
61
) }
78
62
</ div >
79
- { visibleFrames . map ( ( frame , frameIndex ) => (
80
- < CallStackFrame
81
- key = { `call-stack-leading-${ frameIndex } ` }
82
- frame = { frame }
83
- index = { frameIndex }
84
- />
85
- ) ) }
86
-
87
- { isIgnoreListOpen && (
88
- < >
89
- { ignoredFrames . map ( ( frame , frameIndex ) => (
90
- < CallStackFrame
91
- key = { `call-stack-ignored-${ frameIndex } ` }
92
- frame = { frame }
93
- index = { frameIndex }
94
- />
95
- ) ) }
96
- </ >
97
- ) }
63
+ { frames . map ( ( frame , frameIndex ) => {
64
+ return ! frame . ignored || isIgnoreListOpen ? (
65
+ < CallStackFrame key = { frameIndex } frame = { frame } index = { frameIndex } />
66
+ ) : null
67
+ } ) }
98
68
</ div >
99
69
)
100
70
}
0 commit comments