Summary: Added selection source concept to onSelect callback. This allows us to only autoscroll the tree when selection source is the visualiser. We had feedback that the horizontal autoscrolling whilst using the tree was unhelpful. A side benefit of selection source is better tracking of how people use kb, tree vs visualiser to select things Changelog: UIDebugger only autoscroll horizontally when selecting via the visualiser Reviewed By: lblasa Differential Revision: D47334078 fbshipit-source-id: d7eadddb8d3d0fd428d5c294b2dccc2f1efa5a95
32 lines
790 B
TypeScript
32 lines
790 B
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {Atom} from 'flipper-plugin';
|
|
import {useEffect, useRef, useState} from 'react';
|
|
|
|
export function useDelay(delayTimeMs: number) {
|
|
const [isDone, setIsDone] = useState(false);
|
|
const delayTimerStarted = useRef(false);
|
|
useEffect(() => {
|
|
let handle: NodeJS.Timeout | null = null;
|
|
if (delayTimerStarted.current === false) {
|
|
handle = setTimeout(() => setIsDone(true), delayTimeMs);
|
|
delayTimerStarted.current = true;
|
|
}
|
|
|
|
return () => {
|
|
if (handle !== null) {
|
|
clearTimeout(handle);
|
|
}
|
|
};
|
|
}, [delayTimeMs]);
|
|
|
|
return isDone;
|
|
}
|