diff --git a/src/actions/profile-view.ts b/src/actions/profile-view.ts index 5cc91261f3..43af88bb8b 100644 --- a/src/actions/profile-view.ts +++ b/src/actions/profile-view.ts @@ -1749,13 +1749,17 @@ export function changeShowJsTracerSummary( } export function updatePreviewSelection( - previewSelection: PreviewSelection + previewSelection: PreviewSelection | null ): ThunkAction { return (dispatch, getState) => { + // Only dispatch if the selection changes. This function can fire in a tight loop, + // and this check saves a dispatch. const currentPreviewSelection = getPreviewSelection(getState()); - if (!objectShallowEquals(currentPreviewSelection, previewSelection)) { - // Only dispatch if the selection changes. This function can fire in a tight loop, - // and this check saves a dispatch. + if ( + !currentPreviewSelection || + !previewSelection || + !objectShallowEquals(currentPreviewSelection, previewSelection) + ) { dispatch({ type: 'UPDATE_PREVIEW_SELECTION', previewSelection, diff --git a/src/components/app/BottomBox.tsx b/src/components/app/BottomBox.tsx index 8ab0b1448c..299320261c 100644 --- a/src/components/app/BottomBox.tsx +++ b/src/components/app/BottomBox.tsx @@ -28,7 +28,7 @@ import { getSourceViewCode, getAssemblyViewCode, } from 'firefox-profiler/selectors/code'; -import { getPreviewSelection } from 'firefox-profiler/selectors/profile'; +import { getPreviewSelectionIsBeingModified } from 'firefox-profiler/selectors/profile'; import explicitConnect from 'firefox-profiler/utils/connect'; import type { ConnectedProps } from 'firefox-profiler/utils/connect'; @@ -295,7 +295,7 @@ export const BottomBox = explicitConnect<{}, StateProps, DispatchProps>({ selectedNodeSelectors.getAssemblyViewAddressTimings(state), assemblyViewScrollGeneration: getAssemblyViewScrollGeneration(state), assemblyViewIsOpen: getAssemblyViewIsOpen(state), - disableOverscan: getPreviewSelection(state).isModifying, + disableOverscan: getPreviewSelectionIsBeingModified(state), }), mapDispatchToProps: { closeBottomBox, diff --git a/src/components/app/ProfileFilterNavigator.tsx b/src/components/app/ProfileFilterNavigator.tsx index 6d43a1ddc5..d4bb3873a8 100644 --- a/src/components/app/ProfileFilterNavigator.tsx +++ b/src/components/app/ProfileFilterNavigator.tsx @@ -187,7 +187,7 @@ export const ProfileFilterNavigator = explicitConnect< const items = getCommittedRangeLabels(state); const previewSelection = getPreviewSelection(state); const profileTimelineUnit = getProfileTimelineUnit(state); - const uncommittedItem = previewSelection.hasSelection + const uncommittedItem = previewSelection ? getFormattedTimelineValue( previewSelection.selectionEnd - previewSelection.selectionStart, profileTimelineUnit diff --git a/src/components/calltree/CallTree.tsx b/src/components/calltree/CallTree.tsx index 082c83c570..02e6b7333d 100644 --- a/src/components/calltree/CallTree.tsx +++ b/src/components/calltree/CallTree.tsx @@ -16,7 +16,7 @@ import { import { getScrollToSelectionGeneration, getFocusCallTreeGeneration, - getPreviewSelection, + getPreviewSelectionIsBeingModified, getCategories, getCurrentTableViewOptions, } from 'firefox-profiler/selectors/profile'; @@ -410,7 +410,7 @@ export const CallTree = explicitConnect<{}, StateProps, DispatchProps>({ expandedCallNodeIndexes: selectedThreadSelectors.getExpandedCallNodeIndexes(state), searchStringsRegExp: getSearchStringsAsRegExp(state), - disableOverscan: getPreviewSelection(state).isModifying, + disableOverscan: getPreviewSelectionIsBeingModified(state), invertCallstack: getInvertCallstack(state), implementationFilter: getImplementationFilter(state), // Use the filtered call node max depth, rather than the preview filtered call node diff --git a/src/components/flame-graph/FlameGraph.tsx b/src/components/flame-graph/FlameGraph.tsx index 3b733e11e6..7eaf02af41 100644 --- a/src/components/flame-graph/FlameGraph.tsx +++ b/src/components/flame-graph/FlameGraph.tsx @@ -74,7 +74,7 @@ type StateProps = { readonly ctssSampleIndexOffset: number; readonly maxStackDepthPlusOne: number; readonly timeRange: StartEndRange; - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; readonly flameGraphTiming: FlameGraphTiming; readonly callTree: CallTree; readonly callNodeInfo: CallNodeInfo; diff --git a/src/components/js-tracer/Canvas.tsx b/src/components/js-tracer/Canvas.tsx index c748609d75..abed86ac95 100644 --- a/src/components/js-tracer/Canvas.tsx +++ b/src/components/js-tracer/Canvas.tsx @@ -608,7 +608,6 @@ class JsTracerCanvasImpl extends React.PureComponent { // const { markers, updatePreviewSelection } = this.props; // const marker = markers[eventIndex]; // updatePreviewSelection({ - // hasSelection: true, // isModifying: false, // selectionStart: marker.start, // selectionEnd: marker.start + marker.dur, diff --git a/src/components/js-tracer/Chart.tsx b/src/components/js-tracer/Chart.tsx index afea714125..c980c96d93 100644 --- a/src/components/js-tracer/Chart.tsx +++ b/src/components/js-tracer/Chart.tsx @@ -53,7 +53,7 @@ type StateProps = { readonly stringTable: StringTable; readonly timeRange: StartEndRange; readonly threadsKey: ThreadsKey; - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; }; type Props = ConnectedProps; diff --git a/src/components/marker-chart/Canvas.tsx b/src/components/marker-chart/Canvas.tsx index b8d72b5349..5964f4599c 100644 --- a/src/components/marker-chart/Canvas.tsx +++ b/src/components/marker-chart/Canvas.tsx @@ -775,7 +775,6 @@ class MarkerChartCanvasImpl extends React.PureComponent { ); updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: start, selectionEnd: end, diff --git a/src/components/marker-chart/index.tsx b/src/components/marker-chart/index.tsx index 4e487ddeeb..ec93715ef0 100644 --- a/src/components/marker-chart/index.tsx +++ b/src/components/marker-chart/index.tsx @@ -56,7 +56,7 @@ type StateProps = { readonly markerListLength: number; readonly timeRange: StartEndRange; readonly threadsKey: ThreadsKey; - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; readonly rightClickedMarkerIndex: MarkerIndex | null; readonly selectedMarkerIndex: MarkerIndex | null; }; diff --git a/src/components/network-chart/index.tsx b/src/components/network-chart/index.tsx index 3d61cd247d..07ba63baec 100644 --- a/src/components/network-chart/index.tsx +++ b/src/components/network-chart/index.tsx @@ -19,7 +19,7 @@ import { import { getScrollToSelectionGeneration, - getPreviewSelection, + getPreviewSelectionIsBeingModified, getPreviewSelectionRange, } from '../../selectors/profile'; import { selectedThreadSelectors } from '../../selectors/per-thread'; @@ -422,7 +422,7 @@ export const NetworkChart = explicitConnect< hoveredMarkerIndexFromState: selectedThreadSelectors.getHoveredMarkerIndex(state), timeRange: getPreviewSelectionRange(state), - disableOverscan: getPreviewSelection(state).isModifying, + disableOverscan: getPreviewSelectionIsBeingModified(state), threadsKey: getSelectedThreadsKey(state), }), mapDispatchToProps: { diff --git a/src/components/shared/Draggable.tsx b/src/components/shared/Draggable.tsx index a1094eace1..c463d035e6 100644 --- a/src/components/shared/Draggable.tsx +++ b/src/components/shared/Draggable.tsx @@ -3,24 +3,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react'; -import type { Milliseconds } from 'firefox-profiler/types'; -export type OnMove = ( - originalValue: { - readonly selectionEnd: Milliseconds; - readonly selectionStart: Milliseconds; - }, +export type OnMove = ( + originalValue: T, dx: number, dy: number, isModifying: boolean ) => void; -type Props = { - value: { - readonly selectionStart: Milliseconds; - readonly selectionEnd: Milliseconds; - }; - onMove: OnMove; +type Props = { + value: T; + onMove: OnMove; className: string; children?: React.ReactNode; }; @@ -37,7 +30,7 @@ type State = { * x and y deltas compared to the mouse position at mousedown. * During the drag, the additional className 'dragging' is set on the element. */ -export class Draggable extends React.PureComponent { +export class Draggable extends React.PureComponent, State> { _container: HTMLDivElement | null = null; _handlers: { mouseMoveHandler: (param: MouseEvent) => void; diff --git a/src/components/shared/MarkerContextMenu.tsx b/src/components/shared/MarkerContextMenu.tsx index a513c646c8..bd4a4a8fe2 100644 --- a/src/components/shared/MarkerContextMenu.tsx +++ b/src/components/shared/MarkerContextMenu.tsx @@ -52,7 +52,7 @@ type OwnProps = { type StateProps = { readonly marker: Marker; readonly markerIndex: MarkerIndex; - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; readonly committedRange: StartEndRange; readonly thread: Thread | null; readonly implementationFilter: ImplementationFilter; @@ -74,12 +74,11 @@ class MarkerContextMenuImpl extends PureComponent { const { updatePreviewSelection, previewSelection, committedRange } = this.props; - const selectionEnd = previewSelection.hasSelection + const selectionEnd = previewSelection ? previewSelection.selectionEnd : committedRange.end; updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart, selectionEnd, @@ -90,7 +89,7 @@ class MarkerContextMenuImpl extends PureComponent { const { updatePreviewSelection, committedRange, previewSelection } = this.props; - const selectionStart = previewSelection.hasSelection + const selectionStart = previewSelection ? previewSelection.selectionStart : committedRange.start; @@ -102,7 +101,6 @@ class MarkerContextMenuImpl extends PureComponent { } updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart, selectionEnd, @@ -137,7 +135,6 @@ class MarkerContextMenuImpl extends PureComponent { } updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: marker.start, selectionEnd: marker.end, @@ -385,11 +382,11 @@ class MarkerContextMenuImpl extends PureComponent { const { marker, previewSelection, committedRange } = this.props; const { data } = marker; - const selectionEnd = previewSelection.hasSelection + const selectionEnd = previewSelection ? previewSelection.selectionEnd : committedRange.end; - const selectionStart = previewSelection.hasSelection + const selectionStart = previewSelection ? previewSelection.selectionStart : committedRange.start; diff --git a/src/components/shared/chart/Viewport.tsx b/src/components/shared/chart/Viewport.tsx index 6f9c989290..4471702639 100644 --- a/src/components/shared/chart/Viewport.tsx +++ b/src/components/shared/chart/Viewport.tsx @@ -145,7 +145,7 @@ type ViewportProps = { // The "committed range", whose endpoints correspond to 0 and 1. readonly timeRange: StartEndRange; // The preview selection, whose endpoints correspond to viewportLeft and viewportRight. - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; // The left margin. Margins are outside the viewport but inside containerWidth. readonly marginLeft: CssPixels; // The right margin. Margins are outside the viewport but inside containerWidth. @@ -214,7 +214,7 @@ class ChartViewportImpl extends React.PureComponent< > { zoomScrollId: number = 0; _pendingPreviewSelectionUpdates: Array< - (horizontalViewport: HorizontalViewport) => PreviewSelection + (horizontalViewport: HorizontalViewport) => PreviewSelection | null > = []; _container: HTMLDivElement | null = null; _takeContainerRef = (container: HTMLDivElement) => { @@ -235,10 +235,10 @@ class ChartViewportImpl extends React.PureComponent< } getHorizontalViewport( - previewSelection: PreviewSelection, + previewSelection: PreviewSelection | null, timeRange: StartEndRange ) { - if (previewSelection.hasSelection) { + if (previewSelection) { const { selectionStart, selectionEnd } = previewSelection; const timeRangeLength = timeRange.end - timeRange.start; return { @@ -433,7 +433,7 @@ class ChartViewportImpl extends React.PureComponent< * processes all queued updates from a requestAnimationFrame callback. */ _addBatchedPreviewSelectionUpdate( - callback: (param: HorizontalViewport) => PreviewSelection + callback: (param: HorizontalViewport) => PreviewSelection | null ) { if (this._pendingPreviewSelectionUpdates.length === 0) { requestAnimationFrame(() => this._flushPendingPreviewSelectionUpdates()); @@ -532,14 +532,10 @@ class ChartViewportImpl extends React.PureComponent< viewportProps: { timeRange }, } = this.props; if (newViewportLeft === 0 && newViewportRight === 1) { - return { - hasSelection: false, - isModifying: false, - }; + return null; } const timeRangeLength = timeRange.end - timeRange.start; return { - hasSelection: true, isModifying: false, selectionStart: timeRange.start + timeRangeLength * newViewportLeft, selectionEnd: timeRange.start + timeRangeLength * newViewportRight, @@ -722,10 +718,7 @@ class ChartViewportImpl extends React.PureComponent< // Calculate left and right in terms of the unit interval of the profile range. const viewportLength = viewportRight - viewportLeft; if (viewportLength >= 1) { - return { - hasSelection: false, - isModifying: false, - }; + return null; } const viewportPixelWidth = containerWidth - marginLeft - marginRight; const unitOffsetX = offsetX * (viewportLength / viewportPixelWidth); @@ -742,7 +735,6 @@ class ChartViewportImpl extends React.PureComponent< const timeRangeLength = timeRange.end - timeRange.start; return { - hasSelection: true, isModifying: false, selectionStart: timeRange.start + timeRangeLength * newViewportLeft, selectionEnd: timeRange.start + timeRangeLength * newViewportRight, diff --git a/src/components/stack-chart/Canvas.tsx b/src/components/stack-chart/Canvas.tsx index 2cf2433a11..d158b1d7ff 100644 --- a/src/components/stack-chart/Canvas.tsx +++ b/src/components/stack-chart/Canvas.tsx @@ -641,7 +641,6 @@ class StackChartCanvasImpl extends React.PureComponent { const { depth, stackTimingIndex } = hoveredItem; const { combinedTimingRows, updatePreviewSelection } = this.props; updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: combinedTimingRows[depth].start[stackTimingIndex], selectionEnd: combinedTimingRows[depth].end[stackTimingIndex], diff --git a/src/components/stack-chart/index.tsx b/src/components/stack-chart/index.tsx index 7821773da6..d2fdf4fa5e 100644 --- a/src/components/stack-chart/index.tsx +++ b/src/components/stack-chart/index.tsx @@ -72,7 +72,7 @@ type StateProps = { readonly sameWidthsIndexToTimestampMap: SameWidthsIndexToTimestampMap; readonly timeRange: StartEndRange; readonly interval: Milliseconds; - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; readonly threadsKey: ThreadsKey; readonly callNodeInfo: CallNodeInfo; readonly categories: CategoryList; diff --git a/src/components/timeline/Markers.tsx b/src/components/timeline/Markers.tsx index 271cdf71ef..0a37b550f5 100644 --- a/src/components/timeline/Markers.tsx +++ b/src/components/timeline/Markers.tsx @@ -14,7 +14,7 @@ import { Tooltip } from 'firefox-profiler/components/tooltip/Tooltip'; import { TooltipMarker } from 'firefox-profiler/components/tooltip/Marker'; import { timeCode } from 'firefox-profiler/utils/time-code'; import explicitConnect from 'firefox-profiler/utils/connect'; -import { getPreviewSelection } from 'firefox-profiler/selectors/profile'; +import { getPreviewSelectionIsBeingModified } from 'firefox-profiler/selectors/profile'; import { getThreadSelectorsFromThreadsKey } from 'firefox-profiler/selectors/per-thread'; import { getSelectedThreadIndexes } from 'firefox-profiler/selectors/url-state'; import { changeRightClickedMarker } from 'firefox-profiler/actions/profile-view'; @@ -528,7 +528,7 @@ export const TimelineMarkersJank = explicitConnect< // These don't use marker schema as they are derived. markerIndexes: selectors.getTimelineJankMarkerIndexes(state), isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey), - isModifyingSelection: getPreviewSelection(state).isModifying, + isModifyingSelection: getPreviewSelectionIsBeingModified(state), testId: 'TimelineMarkersJank', rightClickedMarker: selectors.getRightClickedMarker(state), }; @@ -557,7 +557,7 @@ export const TimelineMarkersOverview = explicitConnect< getMarker: selectors.getMarkerGetter(state), markerIndexes: selectors.getTimelineOverviewMarkerIndexes(state), isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey), - isModifyingSelection: getPreviewSelection(state).isModifying, + isModifyingSelection: getPreviewSelectionIsBeingModified(state), testId: 'TimelineMarkersOverview', rightClickedMarker: selectors.getRightClickedMarker(state), }; @@ -583,7 +583,7 @@ export const TimelineMarkersFileIo = explicitConnect< getMarker: selectors.getMarkerGetter(state), markerIndexes: selectors.getTimelineFileIoMarkerIndexes(state), isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey), - isModifyingSelection: getPreviewSelection(state).isModifying, + isModifyingSelection: getPreviewSelectionIsBeingModified(state), testId: 'TimelineMarkersFileIo', rightClickedMarker: selectors.getRightClickedMarker(state), }; @@ -609,7 +609,7 @@ export const TimelineMarkersMemory = explicitConnect< getMarker: selectors.getMarkerGetter(state), markerIndexes: selectors.getTimelineMemoryMarkerIndexes(state), isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey), - isModifyingSelection: getPreviewSelection(state).isModifying, + isModifyingSelection: getPreviewSelectionIsBeingModified(state), additionalClassName: 'timelineMarkersMemory', testId: 'TimelineMarkersMemory', rightClickedMarker: selectors.getRightClickedMarker(state), @@ -636,7 +636,7 @@ export const TimelineMarkersIPC = explicitConnect< getMarker: selectors.getMarkerGetter(state), markerIndexes: selectors.getTimelineIPCMarkerIndexes(state), isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey), - isModifyingSelection: getPreviewSelection(state).isModifying, + isModifyingSelection: getPreviewSelectionIsBeingModified(state), additionalClassName: 'timelineMarkersIPC', testId: 'TimelineMarkersIPC', rightClickedMarker: selectors.getRightClickedMarker(state), diff --git a/src/components/timeline/Selection.tsx b/src/components/timeline/Selection.tsx index f1b7ef5caa..f7a56fd5bf 100644 --- a/src/components/timeline/Selection.tsx +++ b/src/components/timeline/Selection.tsx @@ -41,7 +41,7 @@ type OwnProps = { }; type StateProps = { - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; readonly committedRange: StartEndRange; readonly zeroAt: Milliseconds; readonly profileTimelineUnit: string; @@ -139,10 +139,9 @@ class TimelineRulerAndSelection extends React.PureComponent { isRangeSelecting = false; this._uninstallMoveAndClickHandlers(); - if (previewSelection.hasSelection) { + if (previewSelection) { const { selectionStart, selectionEnd } = previewSelection; this.props.updatePreviewSelection({ - hasSelection: true, selectionStart, selectionEnd, isModifying: false, @@ -158,7 +157,6 @@ class TimelineRulerAndSelection extends React.PureComponent { isRangeSelecting = true; const { selectionStart, selectionEnd } = getSelectionFromEvent(event); this.props.updatePreviewSelection({ - hasSelection: true, selectionStart, selectionEnd, isModifying: true, @@ -171,7 +169,6 @@ class TimelineRulerAndSelection extends React.PureComponent { // This click ends the current selection gesture. const { selectionStart, selectionEnd } = getSelectionFromEvent(event); this.props.updatePreviewSelection({ - hasSelection: true, selectionStart, selectionEnd, isModifying: false, @@ -187,7 +184,7 @@ class TimelineRulerAndSelection extends React.PureComponent { // there may be one from a previous selection operation). const { previewSelection } = this.props; - if (previewSelection.hasSelection) { + if (previewSelection) { // There's a selection. // Dismiss it but only if the click is outside the current selection. const clickTime = @@ -201,10 +198,7 @@ class TimelineRulerAndSelection extends React.PureComponent { event.stopPropagation(); // Unset preview selection. - this.props.updatePreviewSelection({ - hasSelection: false, - isModifying: false, - }); + this.props.updatePreviewSelection(null); } } @@ -270,45 +264,55 @@ class TimelineRulerAndSelection extends React.PureComponent { this.props.changeMouseTimePosition(null); }; - _makeOnMove = - (fun: (dx: number) => { startDelta: number; endDelta: number }) => - ( - originalSelection: { - readonly selectionStart: number; - readonly selectionEnd: number; - }, + _makeOnMove = ( + fun: (dx: number) => { startDelta: number; endDelta: number } + ) => { + return ( + originalSelection: PreviewSelection, dx: number, - dy: number, + _dy: number, isModifying: boolean ) => { - const { committedRange, width, updatePreviewSelection } = this.props; - const delta = (dx / width) * (committedRange.end - committedRange.start); - const selectionDeltas = fun(delta); - let selectionStart = clamp( - originalSelection.selectionStart + selectionDeltas.startDelta, - committedRange.start, - committedRange.end - ); - let selectionEnd = clamp( - originalSelection.selectionEnd + selectionDeltas.endDelta, - committedRange.start, - committedRange.end - ); - let draggingStart = isModifying && !!selectionDeltas.startDelta; - let draggingEnd = isModifying && !!selectionDeltas.endDelta; - if (selectionStart > selectionEnd) { - [selectionStart, selectionEnd] = [selectionEnd, selectionStart]; - [draggingStart, draggingEnd] = [draggingEnd, draggingStart]; - } - updatePreviewSelection({ - hasSelection: true, - isModifying, - selectionStart, - selectionEnd, - draggingStart, - draggingEnd, - }); + this._onMove(originalSelection, fun, dx, isModifying); }; + }; + + _onMove( + originalSelection: PreviewSelection, + selectionDeltasForDx: (dx: number) => { + startDelta: number; + endDelta: number; + }, + dx: number, + isModifying: boolean + ) { + const { committedRange, width, updatePreviewSelection } = this.props; + const delta = (dx / width) * (committedRange.end - committedRange.start); + const selectionDeltas = selectionDeltasForDx(delta); + let selectionStart = clamp( + originalSelection.selectionStart + selectionDeltas.startDelta, + committedRange.start, + committedRange.end + ); + let selectionEnd = clamp( + originalSelection.selectionEnd + selectionDeltas.endDelta, + committedRange.start, + committedRange.end + ); + let draggingStart = isModifying && !!selectionDeltas.startDelta; + let draggingEnd = isModifying && !!selectionDeltas.endDelta; + if (selectionStart > selectionEnd) { + [selectionStart, selectionEnd] = [selectionEnd, selectionStart]; + [draggingStart, draggingEnd] = [draggingEnd, draggingStart]; + } + updatePreviewSelection({ + isModifying, + selectionStart, + selectionEnd, + draggingStart, + draggingEnd, + }); + } _rangeStartOnMove = this._makeOnMove((delta) => ({ startDelta: delta, @@ -332,7 +336,7 @@ class TimelineRulerAndSelection extends React.PureComponent { _zoomButtonOnClick = (e: React.MouseEvent) => { e.stopPropagation(); const { previewSelection, zeroAt, commitRange } = this.props; - if (previewSelection.hasSelection) { + if (previewSelection) { commitRange( previewSelection.selectionStart - zeroAt, previewSelection.selectionEnd - zeroAt @@ -340,13 +344,7 @@ class TimelineRulerAndSelection extends React.PureComponent { } }; - renderSelectionOverlay(previewSelection: { - readonly selectionStart: number; - readonly selectionEnd: number; - readonly isModifying: boolean; - readonly draggingStart?: boolean; - readonly draggingEnd?: boolean; - }) { + renderSelectionOverlay(previewSelection: PreviewSelection) { const { committedRange, width, profileTimelineUnit } = this.props; const { selectionStart, selectionEnd } = previewSelection; @@ -464,14 +462,14 @@ class TimelineRulerAndSelection extends React.PureComponent { onMouseLeave={this._onMouseLeave} > {children} - {previewSelection.hasSelection + {previewSelection ? this.renderSelectionOverlay(previewSelection) : null}
{ const unitGraphCount = samples.count[counterIndex] / sampleTimeDeltaInMs; let rangeTotal = 0; - if (previewSelection.hasSelection) { + if (previewSelection) { const [beginIndex, endIndex] = getSampleIndexRangeForSelection( samples, previewSelection.selectionStart, @@ -556,7 +556,7 @@ class TrackBandwidthGraphImpl extends React.PureComponent { countRange, 'TrackBandwidthGraph--total-bandwidth-in-graph' )} - {previewSelection.hasSelection + {previewSelection ? this._formatDataTransferValue( rangeTotal, 'TrackBandwidthGraph--total-bandwidth-in-range' diff --git a/src/components/timeline/TrackIPC.tsx b/src/components/timeline/TrackIPC.tsx index 569b79f096..b2e49c6fe2 100644 --- a/src/components/timeline/TrackIPC.tsx +++ b/src/components/timeline/TrackIPC.tsx @@ -39,7 +39,6 @@ export class TrackIPCImpl extends React.PureComponent { _onMarkerSelect = (start: Milliseconds, end: Milliseconds) => { const { rangeStart, rangeEnd, updatePreviewSelection } = this.props; updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: Math.max(rangeStart, start), selectionEnd: Math.min(rangeEnd, end), diff --git a/src/components/timeline/TrackMemory.tsx b/src/components/timeline/TrackMemory.tsx index fee25ea67d..7c0dc3cf00 100644 --- a/src/components/timeline/TrackMemory.tsx +++ b/src/components/timeline/TrackMemory.tsx @@ -49,7 +49,6 @@ export class TrackMemoryImpl extends React.PureComponent { _onMarkerSelect = (start: Milliseconds, end: Milliseconds) => { const { rangeStart, rangeEnd, updatePreviewSelection } = this.props; updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: Math.max(rangeStart, start), selectionEnd: Math.min(rangeEnd, end), diff --git a/src/components/timeline/TrackNetwork.tsx b/src/components/timeline/TrackNetwork.tsx index 4cd94503e9..c2ff5083e4 100644 --- a/src/components/timeline/TrackNetwork.tsx +++ b/src/components/timeline/TrackNetwork.tsx @@ -14,7 +14,7 @@ import { getCommittedRange, getZeroAt, getInnerWindowIDToPageMap, - getPreviewSelection, + getPreviewSelectionIsBeingModified, } from 'firefox-profiler/selectors/profile'; import { getThreadSelectors } from 'firefox-profiler/selectors/per-thread'; import { @@ -432,7 +432,7 @@ export const TrackNetwork = explicitConnect< rangeStart: start, rangeEnd: end, zeroAt: getZeroAt(state), - isModifyingSelection: getPreviewSelection(state).isModifying, + isModifyingSelection: getPreviewSelectionIsBeingModified(state), verticalMarkerIndexes: selectors.getTimelineVerticalMarkerIndexes(state), rightClickedMarkerIndex: selectors.getRightClickedMarkerIndex(state), selectedNetworkMarkerIndex: diff --git a/src/components/timeline/TrackScreenshots.tsx b/src/components/timeline/TrackScreenshots.tsx index 1eef18ed38..4ec906de4e 100644 --- a/src/components/timeline/TrackScreenshots.tsx +++ b/src/components/timeline/TrackScreenshots.tsx @@ -6,7 +6,7 @@ import { PureComponent } from 'react'; import explicitConnect from 'firefox-profiler/utils/connect'; import { getCommittedRange, - getPreviewSelection, + getPreviewSelectionIsBeingModified, } from 'firefox-profiler/selectors/profile'; import { getThreadSelectors } from 'firefox-profiler/selectors/per-thread'; import { @@ -117,7 +117,6 @@ class Screenshots extends PureComponent { return; } updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: start, selectionEnd: end, @@ -190,7 +189,6 @@ export const TimelineTrackScreenshots = explicitConnect< const { threadIndex, windowId } = ownProps; const selectors = getThreadSelectors(threadIndex); const { start, end } = getCommittedRange(state); - const previewSelection = getPreviewSelection(state); return { thread: selectors.getRangeFilteredThread(state), screenshots: @@ -199,8 +197,7 @@ export const TimelineTrackScreenshots = explicitConnect< threadName: selectors.getFriendlyThreadName(state), rangeStart: start, rangeEnd: end, - isMakingPreviewSelection: - previewSelection.hasSelection && previewSelection.isModifying, + isMakingPreviewSelection: getPreviewSelectionIsBeingModified(state), }; }, mapDispatchToProps: { diff --git a/src/components/timeline/TrackThread.tsx b/src/components/timeline/TrackThread.tsx index cc7068d193..a69c91c07e 100644 --- a/src/components/timeline/TrackThread.tsx +++ b/src/components/timeline/TrackThread.tsx @@ -153,7 +153,6 @@ class TimelineTrackThreadImpl extends PureComponent { _onMarkerSelect = (start: Milliseconds, end: Milliseconds) => { const { rangeStart, rangeEnd, updatePreviewSelection } = this.props; updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: Math.max(rangeStart, start), selectionEnd: Math.min(rangeEnd, end), diff --git a/src/components/tooltip/TrackPower.tsx b/src/components/tooltip/TrackPower.tsx index b0490e12d4..062abd0aab 100644 --- a/src/components/tooltip/TrackPower.tsx +++ b/src/components/tooltip/TrackPower.tsx @@ -38,7 +38,7 @@ type StateProps = { interval: Milliseconds; meta: ProfileMeta; committedRange: StartEndRange; - previewSelection: PreviewSelection; + previewSelection: PreviewSelection | null; }; type Props = ConnectedProps; @@ -123,9 +123,9 @@ class TooltipTrackPowerImpl extends React.PureComponent { } maybeRenderForPreviewSelection( - previewSelection: PreviewSelection + previewSelection: PreviewSelection | null ): React.ReactElement | null { - if (!previewSelection.hasSelection) { + if (!previewSelection) { return null; } diff --git a/src/reducers/profile-view.ts b/src/reducers/profile-view.ts index 68ac0fc71e..6039d1f810 100644 --- a/src/reducers/profile-view.ts +++ b/src/reducers/profile-view.ts @@ -529,21 +529,20 @@ const waitingForLibs: Reducer> = ( } }; -const previewSelection: Reducer = ( - state = { hasSelection: false, isModifying: false }, +const previewSelection: Reducer = ( + state = null, action ) => { switch (action.type) { case 'UPDATE_PREVIEW_SELECTION': return action.previewSelection; case 'COMMIT_RANGE': - return { hasSelection: false, isModifying: false }; + return null; case 'POP_COMMITTED_RANGES': if (!action.committedRange) { - return { hasSelection: false, isModifying: false }; + return null; } return { - hasSelection: true, isModifying: false, selectionStart: action.committedRange.start, selectionEnd: action.committedRange.end, diff --git a/src/selectors/per-thread/markers.ts b/src/selectors/per-thread/markers.ts index 59a9ab4d7a..7f8bf72048 100644 --- a/src/selectors/per-thread/markers.ts +++ b/src/selectors/per-thread/markers.ts @@ -279,7 +279,7 @@ export function getMarkerSelectorsPerThread( getSearchFilteredMarkerIndexes, ProfileSelectors.getPreviewSelection, (getMarker, markerIndexes, previewSelection) => { - if (!previewSelection.hasSelection) { + if (!previewSelection) { return markerIndexes; } const { selectionStart, selectionEnd } = previewSelection; diff --git a/src/selectors/per-thread/thread.tsx b/src/selectors/per-thread/thread.tsx index bf1eff56c6..30a939f7c1 100644 --- a/src/selectors/per-thread/thread.tsx +++ b/src/selectors/per-thread/thread.tsx @@ -473,7 +473,7 @@ export function getThreadSelectorsWithMarkersPerThread( getFilteredThread, ProfileSelectors.getPreviewSelection, (thread, previewSelection): Thread => { - if (!previewSelection.hasSelection) { + if (!previewSelection) { return thread; } const { selectionStart, selectionEnd } = previewSelection; @@ -521,7 +521,7 @@ export function getThreadSelectorsWithMarkersPerThread( ProfileSelectors.getPreviewSelection, threadSelectors.getFilteredCtssSampleIndexOffset, (samples, previewSelection, sampleIndexFromCommittedRange) => { - if (!previewSelection.hasSelection) { + if (!previewSelection) { return sampleIndexFromCommittedRange; } diff --git a/src/selectors/profile.ts b/src/selectors/profile.ts index 60d06fe102..791dac37b8 100644 --- a/src/selectors/profile.ts +++ b/src/selectors/profile.ts @@ -137,9 +137,16 @@ export const getTableViewOptionSelectors: ( return options || defaultTableViewOptions; }; -export const getPreviewSelection: Selector = (state) => +export const getPreviewSelection: Selector = (state) => getProfileViewOptions(state).previewSelection; +export const getPreviewSelectionIsBeingModified: Selector = ( + state +) => { + const previewSelection = getPreviewSelection(state); + return previewSelection ? previewSelection.isModifying : false; +}; + /** * This selector returns the current range, taking into account the current * preview selection if any. @@ -148,7 +155,7 @@ export const getPreviewSelectionRange: Selector = createSelector( getCommittedRange, getPreviewSelection, (committedRange, previewSelection) => { - if (previewSelection.hasSelection) { + if (previewSelection) { return { start: previewSelection.selectionStart, end: previewSelection.selectionEnd, diff --git a/src/test/components/FilterNavigatorBar.test.tsx b/src/test/components/FilterNavigatorBar.test.tsx index 3b797a7316..b572bddc12 100644 --- a/src/test/components/FilterNavigatorBar.test.tsx +++ b/src/test/components/FilterNavigatorBar.test.tsx @@ -115,7 +115,6 @@ describe('app/ProfileFilterNavigator', () => { act(() => { dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 10, selectionEnd: 10.1, diff --git a/src/test/components/FlameGraph.test.tsx b/src/test/components/FlameGraph.test.tsx index 21fd7ec37f..4b3bcf514e 100644 --- a/src/test/components/FlameGraph.test.tsx +++ b/src/test/components/FlameGraph.test.tsx @@ -201,7 +201,6 @@ describe('FlameGraph', function () { act(() => { dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 1.3, selectionEnd: 5, @@ -246,7 +245,6 @@ describe('FlameGraph', function () { act(() => { dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 5, selectionEnd: 10, diff --git a/src/test/components/MarkerChart.test.tsx b/src/test/components/MarkerChart.test.tsx index ab4f24645f..cb63c1df6f 100644 --- a/src/test/components/MarkerChart.test.tsx +++ b/src/test/components/MarkerChart.test.tsx @@ -650,7 +650,6 @@ describe('MarkerChart', function () { clickOnMenuItem(/start.*start/i); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 2, selectionEnd: 11, @@ -658,7 +657,6 @@ describe('MarkerChart', function () { clickOnMenuItem(/start.*end/i); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 8, selectionEnd: 11, @@ -667,7 +665,6 @@ describe('MarkerChart', function () { // This one doesn't work because it's disabled. clickOnMenuItem(/end.*start/i); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 8, selectionEnd: 11, @@ -677,7 +674,6 @@ describe('MarkerChart', function () { rightClick(findFillTextPosition('UserTiming A')); clickOnMenuItem(/start.*start/i); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 11, @@ -687,7 +683,6 @@ describe('MarkerChart', function () { clickOnMenuItem(/end.*start/i); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 2, @@ -695,7 +690,6 @@ describe('MarkerChart', function () { clickOnMenuItem(/end.*end/i); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 8, @@ -710,7 +704,6 @@ describe('MarkerChart', function () { rightClick(findFillTextPosition('UserTiming B')); clickOnMenuItem(/duration/); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 2, selectionEnd: 8, @@ -719,7 +712,6 @@ describe('MarkerChart', function () { rightClick(findFillTextPosition('UserTiming A')); clickOnMenuItem(/duration/); expect(getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 10, diff --git a/src/test/components/MarkerTable.test.tsx b/src/test/components/MarkerTable.test.tsx index dc1fb9a408..2d381ff82a 100644 --- a/src/test/components/MarkerTable.test.tsx +++ b/src/test/components/MarkerTable.test.tsx @@ -99,7 +99,6 @@ describe('MarkerTable', function () { act(() => { dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 10, selectionEnd: 20, diff --git a/src/test/components/NetworkChart.test.tsx b/src/test/components/NetworkChart.test.tsx index 7cd74e9b37..ffc6d3512b 100644 --- a/src/test/components/NetworkChart.test.tsx +++ b/src/test/components/NetworkChart.test.tsx @@ -288,7 +288,6 @@ describe('NetworkChartRowBar phase calculations', function () { act(() => { dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 20, selectionEnd: 40, diff --git a/src/test/components/StackChart.test.tsx b/src/test/components/StackChart.test.tsx index c0fe831e9a..3181a25957 100644 --- a/src/test/components/StackChart.test.tsx +++ b/src/test/components/StackChart.test.tsx @@ -129,7 +129,6 @@ describe('StackChart', function () { act(() => dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 3.1, selectionEnd: 3.4, diff --git a/src/test/components/TrackBandwidth.test.tsx b/src/test/components/TrackBandwidth.test.tsx index 5d5458f9e7..3f208ec09e 100644 --- a/src/test/components/TrackBandwidth.test.tsx +++ b/src/test/components/TrackBandwidth.test.tsx @@ -214,7 +214,6 @@ describe('TrackBandwidth', function () { act(() => { dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 5, selectionEnd: 6, diff --git a/src/test/components/TrackPower.test.tsx b/src/test/components/TrackPower.test.tsx index 065bbf1cdf..402180cec9 100644 --- a/src/test/components/TrackPower.test.tsx +++ b/src/test/components/TrackPower.test.tsx @@ -190,7 +190,6 @@ describe('TrackPower', function () { const { dispatch, moveMouseAtCounter } = setup(); dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 5, selectionEnd: 6, @@ -220,7 +219,6 @@ describe('TrackPower', function () { const { dispatch, moveMouseAtCounter } = setup(); dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 6, selectionEnd: 6, diff --git a/src/test/components/TrackScreenshots.test.tsx b/src/test/components/TrackScreenshots.test.tsx index ed3ae07e6e..43ccf90be8 100644 --- a/src/test/components/TrackScreenshots.test.tsx +++ b/src/test/components/TrackScreenshots.test.tsx @@ -88,7 +88,6 @@ describe('timeline/TrackScreenshots', function () { screenshotClick(LEFT); const expectedPreviewSelection = { - hasSelection: true, isModifying: false, selectionEnd: 1, selectionStart: 0, diff --git a/src/test/components/Viewport.test.tsx b/src/test/components/Viewport.test.tsx index 26e54a3b92..6bbf9a9c32 100644 --- a/src/test/components/Viewport.test.tsx +++ b/src/test/components/Viewport.test.tsx @@ -631,7 +631,7 @@ function setup(profileOverrides: MixedObject = {}) { }; type StateProps = { - previewSelection: PreviewSelection; + previewSelection: PreviewSelection | null; timeRange: StartEndRange; }; diff --git a/src/test/store/actions.test.ts b/src/test/store/actions.test.ts index 4eb46d9524..7c2b2f17c6 100644 --- a/src/test/store/actions.test.ts +++ b/src/test/store/actions.test.ts @@ -392,7 +392,6 @@ describe('selectors/getHasPreviewFilteredCtssSamples', function () { store.dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 1.1, selectionEnd: 1.7, @@ -428,14 +427,10 @@ describe('actions/updatePreviewSelection', function () { const initialSelection = ProfileViewSelectors.getPreviewSelection( store.getState() ); - expect(initialSelection).toEqual({ - hasSelection: false, - isModifying: false, - }); + expect(initialSelection).toBe(null); store.dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 100, selectionEnd: 200, @@ -446,7 +441,6 @@ describe('actions/updatePreviewSelection', function () { store.getState() ); expect(secondSelection).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 100, selectionEnd: 200, diff --git a/src/test/store/profile-view.test.ts b/src/test/store/profile-view.test.ts index f2c53d5b7c..bb3651313c 100644 --- a/src/test/store/profile-view.test.ts +++ b/src/test/store/profile-view.test.ts @@ -1464,20 +1464,15 @@ describe('actions/ProfileView', function () { const { profile } = getProfileFromTextSamples('A'); const { dispatch, getState } = storeWithProfile(profile); - expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: false, - isModifying: false, - }); + expect(ProfileViewSelectors.getPreviewSelection(getState())).toBe(null); dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 1, }) ); expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 1, @@ -1526,7 +1521,6 @@ describe('actions/ProfileView', function () { dispatch(ProfileView.commitRange(0, 10)); dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 1, selectionEnd: 9, @@ -1536,7 +1530,6 @@ describe('actions/ProfileView', function () { { start: 0, end: 10 }, ]); expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 1, selectionEnd: 9, @@ -1553,10 +1546,7 @@ describe('actions/ProfileView', function () { { start: 0, end: 10 }, { start: 2, end: 8 }, ]); - expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: false, - isModifying: false, - }); + expect(ProfileViewSelectors.getPreviewSelection(getState())).toBe(null); expect(ProfileViewSelectors.getPreviewSelectionRange(getState())).toEqual( { start: 2, @@ -1596,14 +1586,12 @@ describe('actions/ProfileView', function () { const { getState, dispatch } = setupStore(); dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 1, selectionEnd: 9, }) ); expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionEnd: 9, selectionStart: 1, @@ -1621,7 +1609,6 @@ describe('actions/ProfileView', function () { { start: 1, end: 9 }, ]); expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 3, selectionEnd: 7, @@ -1643,17 +1630,13 @@ describe('actions/ProfileView', function () { { start: 1, end: 9 }, ]); expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: true, isModifying: false, selectionStart: 3, selectionEnd: 7, }); dispatch(ProfileView.popCommittedRanges(2)); - expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual({ - hasSelection: false, - isModifying: false, - }); + expect(ProfileViewSelectors.getPreviewSelection(getState())).toBe(null); }); }); @@ -1872,7 +1855,6 @@ describe('snapshots of selectors/profile', function () { dispatch(ProfileView.commitRange(3, 7)); // Reminder: upper bound "7" is exclusive. dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 4, selectionEnd: 6, @@ -2382,7 +2364,6 @@ describe('getTimingsForSidebar', () => { dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 3, selectionEnd: 5, @@ -2767,7 +2748,6 @@ describe('getTimingsForSidebar', () => { dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 3, selectionEnd: 5, @@ -3374,7 +3354,6 @@ describe('traced timing', function () { const { start, end } = previewSelection; dispatch( ProfileView.updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: start, selectionEnd: end, diff --git a/src/test/store/zipped-profiles.test.ts b/src/test/store/zipped-profiles.test.ts index 70b2546fe1..aceee2a398 100644 --- a/src/test/store/zipped-profiles.test.ts +++ b/src/test/store/zipped-profiles.test.ts @@ -280,19 +280,15 @@ describe('profile state invalidation when switching between profiles', function // Create new copies of the selection on each assertion and change, so // that we are not relying on strict equality. - const getNoSelection = () => ({ hasSelection: false, isModifying: false }); const getSomeSelection = () => ({ - hasSelection: true, isModifying: true, selectionStart: 0, selectionEnd: 10, }) as PreviewSelection; // It starts with no selection. - expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual( - getNoSelection() - ); + expect(ProfileViewSelectors.getPreviewSelection(getState())).toBe(null); // Add a selection. dispatch(ProfileViewActions.updatePreviewSelection(getSomeSelection())); @@ -303,8 +299,6 @@ describe('profile state invalidation when switching between profiles', function viewProfile('profile2.json'); // It no longer has a selection when viewing another profile. - expect(ProfileViewSelectors.getPreviewSelection(getState())).toEqual( - getNoSelection() - ); + expect(ProfileViewSelectors.getPreviewSelection(getState())).toBe(null); }); }); diff --git a/src/test/unit/js-allocations.test.ts b/src/test/unit/js-allocations.test.ts index 7a3d99e6d4..10f32e64db 100644 --- a/src/test/unit/js-allocations.test.ts +++ b/src/test/unit/js-allocations.test.ts @@ -154,7 +154,6 @@ describe('JS allocation call trees', function () { dispatch(commitRange(0, 1.5)); dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 1, diff --git a/src/test/unit/native-allocations.test.ts b/src/test/unit/native-allocations.test.ts index 9ed2f2b373..ff406eeb66 100644 --- a/src/test/unit/native-allocations.test.ts +++ b/src/test/unit/native-allocations.test.ts @@ -226,7 +226,6 @@ describe('Native allocation call trees', function () { dispatch(commitRange(0, 1.5)); dispatch( updatePreviewSelection({ - hasSelection: true, isModifying: false, selectionStart: 0, selectionEnd: 1, diff --git a/src/types/actions.ts b/src/types/actions.ts index 3ea62bdd1c..ddd300f9fa 100644 --- a/src/types/actions.ts +++ b/src/types/actions.ts @@ -83,16 +83,13 @@ export type DataSource = | 'uploaded-recordings'; export type TimelineType = 'stack' | 'category' | 'cpu-category'; -export type PreviewSelection = - | { readonly hasSelection: false; readonly isModifying: false } - | { - readonly hasSelection: true; - readonly isModifying: boolean; - readonly selectionStart: number; - readonly selectionEnd: number; - readonly draggingStart?: boolean; - readonly draggingEnd?: boolean; - }; +export type PreviewSelection = { + readonly isModifying: boolean; + readonly selectionStart: number; + readonly selectionEnd: number; + readonly draggingStart?: boolean; + readonly draggingEnd?: boolean; +}; /** * The counts for how many tracks are hidden in the timeline. @@ -227,7 +224,7 @@ type ProfileAction = } | { readonly type: 'UPDATE_PREVIEW_SELECTION'; - readonly previewSelection: PreviewSelection; + readonly previewSelection: PreviewSelection | null; } | { readonly type: 'CHANGE_SELECTED_ZIP_FILE'; diff --git a/src/types/state.ts b/src/types/state.ts index e41079e2c3..7c35e49936 100644 --- a/src/types/state.ts +++ b/src/types/state.ts @@ -87,7 +87,7 @@ export type ProfileViewState = { perThread: ThreadViewOptionsPerThreads; symbolicationStatus: SymbolicationStatus; waitingForLibs: Set; - previewSelection: PreviewSelection; + previewSelection: PreviewSelection | null; scrollToSelectionGeneration: number; focusCallTreeGeneration: number; rootRange: StartEndRange;