Skip to content

Commit 375d191

Browse files
committed
Rename 'setStateDebounced' to 'setStateDelayedFlush'
1 parent 1acd5d9 commit 375d191

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

packages/app/src/app/components/Preview/DevTools/Tests/index.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Tests extends React.Component<DevToolProps, State> {
186186
* Every setState call will have to go through this, otherwise we get race conditions
187187
* where the underlying state has changed, but the draftState didn't change.
188188
*/
189-
setStateDebounced = (
189+
setStateDelayedFlush = (
190190
setStateFunc:
191191
| Partial<State>
192192
| ((state: State, props: DevToolProps) => Partial<State>),
@@ -222,7 +222,7 @@ class Tests extends React.Component<DevToolProps, State> {
222222

223223
UNSAFE_componentWillReceiveProps(nextProps: DevToolProps) {
224224
if (nextProps.sandboxId !== this.props.sandboxId) {
225-
this.setStateDebounced(
225+
this.setStateDelayedFlush(
226226
{
227227
files: {},
228228
selectedFilePath: null,
@@ -238,7 +238,7 @@ class Tests extends React.Component<DevToolProps, State> {
238238
}
239239

240240
selectFile = (file: File) => {
241-
this.setStateDebounced(
241+
this.setStateDelayedFlush(
242242
state => ({
243243
selectedFilePath:
244244
file.fileName === state.selectedFilePath ? null : file.fileName,
@@ -248,7 +248,7 @@ class Tests extends React.Component<DevToolProps, State> {
248248
};
249249

250250
toggleFileExpansion = (file: File) => {
251-
this.setStateDebounced(
251+
this.setStateDelayedFlush(
252252
oldState =>
253253
immer(oldState, state => {
254254
state.fileExpansionState[file.fileName] = !state.fileExpansionState[
@@ -283,7 +283,7 @@ class Tests extends React.Component<DevToolProps, State> {
283283
if (this.props.updateStatus) {
284284
this.props.updateStatus('clear');
285285
}
286-
this.setStateDebounced(INITIAL_STATE, 0);
286+
this.setStateDelayedFlush(INITIAL_STATE, 0);
287287
break;
288288
}
289289
case 'test_count': {
@@ -299,7 +299,7 @@ class Tests extends React.Component<DevToolProps, State> {
299299
if (this.props.updateStatus) {
300300
this.props.updateStatus('clear');
301301
}
302-
this.setStateDebounced(
302+
this.setStateDelayedFlush(
303303
{
304304
running: true,
305305
},
@@ -308,7 +308,7 @@ class Tests extends React.Component<DevToolProps, State> {
308308
break;
309309
}
310310
case messages.TOTAL_TEST_END: {
311-
this.setStateDebounced(
311+
this.setStateDelayedFlush(
312312
{
313313
running: false,
314314
},
@@ -338,7 +338,7 @@ class Tests extends React.Component<DevToolProps, State> {
338338
}
339339

340340
case messages.ADD_FILE: {
341-
this.setStateDebounced(oldState =>
341+
this.setStateDelayedFlush(oldState =>
342342
immer(oldState, state => {
343343
state.files[data.path] = {
344344
tests: {},
@@ -351,7 +351,7 @@ class Tests extends React.Component<DevToolProps, State> {
351351
break;
352352
}
353353
case 'remove_file': {
354-
this.setStateDebounced(oldState =>
354+
this.setStateDelayedFlush(oldState =>
355355
immer(oldState, state => {
356356
if (state.files[data.path]) {
357357
delete state.files[data.path];
@@ -363,7 +363,7 @@ class Tests extends React.Component<DevToolProps, State> {
363363
break;
364364
}
365365
case messages.FILE_ERROR: {
366-
this.setStateDebounced(oldState =>
366+
this.setStateDelayedFlush(oldState =>
367367
immer(oldState, state => {
368368
if (state.files[data.path]) {
369369
state.files[data.path].fileError = data.error;
@@ -383,7 +383,7 @@ class Tests extends React.Component<DevToolProps, State> {
383383
case messages.ADD_TEST: {
384384
const testName = [...this.currentDescribeBlocks, data.testName];
385385

386-
this.setStateDebounced(oldState =>
386+
this.setStateDelayedFlush(oldState =>
387387
immer(oldState, state => {
388388
if (!state.files[data.path]) {
389389
state.files[data.path] = {
@@ -409,7 +409,7 @@ class Tests extends React.Component<DevToolProps, State> {
409409
const { test } = data;
410410
const testName = [...test.blocks, test.name];
411411

412-
this.setStateDebounced(oldState =>
412+
this.setStateDelayedFlush(oldState =>
413413
immer(oldState, state => {
414414
if (!state.files[test.path]) {
415415
state.files[test.path] = {
@@ -440,7 +440,7 @@ class Tests extends React.Component<DevToolProps, State> {
440440
const { test } = data;
441441
const testName = [...test.blocks, test.name];
442442

443-
this.setStateDebounced(oldState =>
443+
this.setStateDelayedFlush(oldState =>
444444
immer(oldState, state => {
445445
if (!state.files[test.path]) {
446446
return;
@@ -529,22 +529,22 @@ class Tests extends React.Component<DevToolProps, State> {
529529
};
530530

531531
toggleWatching = () => {
532-
this.setStateDebounced(state => ({ watching: !state.watching }), 0);
532+
this.setStateDelayedFlush(state => ({ watching: !state.watching }), 0);
533533
dispatch({
534534
type: 'set-test-watching',
535535
watching: !this.state.watching,
536536
});
537537
};
538538

539539
runAllTests = () => {
540-
this.setStateDebounced({ files: {} }, 0);
540+
this.setStateDelayedFlush({ files: {} }, 0);
541541
dispatch({
542542
type: 'run-all-tests',
543543
});
544544
};
545545

546546
runTests = (file: File) => {
547-
this.setStateDebounced(
547+
this.setStateDelayedFlush(
548548
oldState =>
549549
immer(oldState, state => {
550550
if (state.files[file.fileName]) {

packages/app/src/app/components/Preview/DevTools/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class DevTools extends React.PureComponent<Props, State> {
149149
* Every setState call will have to go through this, otherwise we get race conditions
150150
* where the underlying state has changed, but the draftState didn't change.
151151
*/
152-
setStateDebounced = (
152+
setStateDelayedFlush = (
153153
setStateFunc:
154154
| Partial<State>
155155
| ((state: State, props: Props) => Partial<State>),
@@ -188,7 +188,7 @@ export class DevTools extends React.PureComponent<Props, State> {
188188
if (typeof this.state.height === 'string') {
189189
const { height } = el.getBoundingClientRect();
190190

191-
this.setStateDebounced({ height }, 0);
191+
this.setStateDelayedFlush({ height }, 0);
192192
}
193193
};
194194

@@ -249,7 +249,7 @@ export class DevTools extends React.PureComponent<Props, State> {
249249

250250
setHidden = (hidden: boolean) => {
251251
if (!hidden) {
252-
return this.setStateDebounced(
252+
return this.setStateDelayedFlush(
253253
state => ({
254254
status: {
255255
...state.status,
@@ -261,7 +261,7 @@ export class DevTools extends React.PureComponent<Props, State> {
261261
);
262262
}
263263

264-
return this.setStateDebounced({ hidden }, 0, () => {
264+
return this.setStateDelayedFlush({ hidden }, 0, () => {
265265
if (this.props.setDevToolsOpen) {
266266
const { setDevToolsOpen } = this.props;
267267
setTimeout(() => setDevToolsOpen(!this.state.hidden), 100);
@@ -276,7 +276,7 @@ export class DevTools extends React.PureComponent<Props, State> {
276276
status: 'success' | 'warning' | 'error' | 'info' | 'clear',
277277
count?: number
278278
) => {
279-
this.setStateDebounced(state => {
279+
this.setStateDelayedFlush(state => {
280280
const currentStatus = (status !== 'clear' && state.status[id]) || {
281281
unread: 0,
282282
type: 'info',
@@ -324,7 +324,7 @@ export class DevTools extends React.PureComponent<Props, State> {
324324
if (!this.state.mouseDown && typeof this.state.height === 'number') {
325325
const { clientY } = event;
326326
unFocus(document, window);
327-
this.setStateDebounced(
327+
this.setStateDelayedFlush(
328328
// @ts-ignore
329329
state => ({
330330
startY: clientY,
@@ -345,7 +345,7 @@ export class DevTools extends React.PureComponent<Props, State> {
345345

346346
handleMouseUp = (e: Event) => {
347347
if (this.state.mouseDown) {
348-
this.setStateDebounced({ mouseDown: false }, 0);
348+
this.setStateDelayedFlush({ mouseDown: false }, 0);
349349
if (this.props.setDragging) {
350350
this.props.setDragging(false);
351351
}
@@ -389,7 +389,7 @@ export class DevTools extends React.PureComponent<Props, State> {
389389
this.state.startHeight - (event.clientY - this.state.startY)
390390
);
391391

392-
this.setStateDebounced(
392+
this.setStateDelayedFlush(
393393
{
394394
height: Math.max(this.closedHeight() - 2, newHeight),
395395
},
@@ -422,7 +422,7 @@ export class DevTools extends React.PureComponent<Props, State> {
422422
TweenMax.to(heightObject, 0.3, {
423423
height: store.get('devtools.height') || 300,
424424
onUpdate: () => {
425-
this.setStateDebounced(heightObject, 0);
425+
this.setStateDelayedFlush(heightObject, 0);
426426
},
427427
ease: Elastic.easeOut.config(0.25, 1),
428428
});
@@ -437,7 +437,7 @@ export class DevTools extends React.PureComponent<Props, State> {
437437
TweenMax.to(heightObject, 0.3, {
438438
height: this.closedHeight(),
439439
onUpdate: () => {
440-
this.setStateDebounced(heightObject, 0);
440+
this.setStateDelayedFlush(heightObject, 0);
441441
},
442442
ease: Elastic.easeOut.config(0.25, 1),
443443
});

0 commit comments

Comments
 (0)