@@ -140,26 +140,26 @@ function getInitialState(
140
140
}
141
141
142
142
export function useErrorOverlayReducer ( routerType : 'pages' | 'app' ) {
143
- return useReducer ( ( _state : OverlayState , action : BusEvent ) : OverlayState => {
143
+ return useReducer ( ( state : OverlayState , action : BusEvent ) : OverlayState => {
144
144
switch ( action . type ) {
145
145
case ACTION_DEBUG_INFO : {
146
- return { ..._state , debugInfo : action . debugInfo }
146
+ return { ...state , debugInfo : action . debugInfo }
147
147
}
148
148
case ACTION_STATIC_INDICATOR : {
149
- return { ..._state , staticIndicator : action . staticIndicator }
149
+ return { ...state , staticIndicator : action . staticIndicator }
150
150
}
151
151
case ACTION_BUILD_OK : {
152
- return { ..._state , buildError : null }
152
+ return { ...state , buildError : null }
153
153
}
154
154
case ACTION_BUILD_ERROR : {
155
- return { ..._state , buildError : action . message }
155
+ return { ...state , buildError : action . message }
156
156
}
157
157
case ACTION_BEFORE_REFRESH : {
158
- return { ..._state , refreshState : { type : 'pending' , errors : [ ] } }
158
+ return { ...state , refreshState : { type : 'pending' , errors : [ ] } }
159
159
}
160
160
case ACTION_REFRESH : {
161
161
return {
162
- ..._state ,
162
+ ...state ,
163
163
buildError : null ,
164
164
errors :
165
165
// Errors can come in during updates. In this case, UNHANDLED_ERROR
@@ -168,56 +168,54 @@ export function useErrorOverlayReducer(routerType: 'pages' | 'app') {
168
168
// around until the next refresh. Otherwise we run into a race
169
169
// condition where those errors would be cleared on refresh completion
170
170
// before they can be displayed.
171
- _state . refreshState . type === 'pending'
172
- ? _state . refreshState . errors
171
+ state . refreshState . type === 'pending'
172
+ ? state . refreshState . errors
173
173
: [ ] ,
174
174
refreshState : { type : 'idle' } ,
175
175
}
176
176
}
177
177
case ACTION_UNHANDLED_ERROR :
178
178
case ACTION_UNHANDLED_REJECTION : {
179
- switch ( _state . refreshState . type ) {
179
+ switch ( state . refreshState . type ) {
180
180
case 'idle' : {
181
181
return {
182
- ..._state ,
183
- nextId : _state . nextId + 1 ,
184
- errors : pushErrorFilterDuplicates ( _state . errors , {
185
- id : _state . nextId ,
182
+ ...state ,
183
+ nextId : state . nextId + 1 ,
184
+ errors : pushErrorFilterDuplicates ( state . errors , {
185
+ id : state . nextId ,
186
186
event : action ,
187
187
} ) ,
188
188
}
189
189
}
190
190
case 'pending' : {
191
191
return {
192
- ..._state ,
193
- nextId : _state . nextId + 1 ,
192
+ ...state ,
193
+ nextId : state . nextId + 1 ,
194
194
refreshState : {
195
- ..._state . refreshState ,
196
- errors : pushErrorFilterDuplicates ( _state . refreshState . errors , {
197
- id : _state . nextId ,
195
+ ...state . refreshState ,
196
+ errors : pushErrorFilterDuplicates ( state . refreshState . errors , {
197
+ id : state . nextId ,
198
198
event : action ,
199
199
} ) ,
200
200
} ,
201
201
}
202
202
}
203
203
default :
204
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
205
- const _ : never = _state . refreshState
206
- return _state
204
+ return state
207
205
}
208
206
}
209
207
case ACTION_VERSION_INFO : {
210
- return { ..._state , versionInfo : action . versionInfo }
208
+ return { ...state , versionInfo : action . versionInfo }
211
209
}
212
210
case ACTION_DEV_INDICATOR : {
213
211
return {
214
- ..._state ,
212
+ ...state ,
215
213
disableDevIndicator :
216
214
shouldDisableDevIndicator || ! ! action . devIndicator . disabledUntil ,
217
215
}
218
216
}
219
217
default : {
220
- return _state
218
+ return state
221
219
}
222
220
}
223
221
} , getInitialState ( routerType ) )
0 commit comments