Skip to content

Commit c2a7ec1

Browse files
committed
Add a selector called getPreviewSelectionIsBeingModified.
This replaces uses where we're assuming that we can access an isModifying property both when we have a preview selection and when we don't have a preview selection. In a future commit I want to make us use null instead of hasSelection==false, and this makes that easier.
1 parent 45ef09c commit c2a7ec1

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

src/components/app/BottomBox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
getSourceViewCode,
2929
getAssemblyViewCode,
3030
} from 'firefox-profiler/selectors/code';
31-
import { getPreviewSelection } from 'firefox-profiler/selectors/profile';
31+
import { getPreviewSelectionIsBeingModified } from 'firefox-profiler/selectors/profile';
3232
import explicitConnect from 'firefox-profiler/utils/connect';
3333

3434
import type { ConnectedProps } from 'firefox-profiler/utils/connect';
@@ -295,7 +295,7 @@ export const BottomBox = explicitConnect<{}, StateProps, DispatchProps>({
295295
selectedNodeSelectors.getAssemblyViewAddressTimings(state),
296296
assemblyViewScrollGeneration: getAssemblyViewScrollGeneration(state),
297297
assemblyViewIsOpen: getAssemblyViewIsOpen(state),
298-
disableOverscan: getPreviewSelection(state).isModifying,
298+
disableOverscan: getPreviewSelectionIsBeingModified(state),
299299
}),
300300
mapDispatchToProps: {
301301
closeBottomBox,

src/components/calltree/CallTree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import {
1717
getScrollToSelectionGeneration,
1818
getFocusCallTreeGeneration,
19-
getPreviewSelection,
19+
getPreviewSelectionIsBeingModified,
2020
getCategories,
2121
getCurrentTableViewOptions,
2222
} from 'firefox-profiler/selectors/profile';
@@ -410,7 +410,7 @@ export const CallTree = explicitConnect<{}, StateProps, DispatchProps>({
410410
expandedCallNodeIndexes:
411411
selectedThreadSelectors.getExpandedCallNodeIndexes(state),
412412
searchStringsRegExp: getSearchStringsAsRegExp(state),
413-
disableOverscan: getPreviewSelection(state).isModifying,
413+
disableOverscan: getPreviewSelectionIsBeingModified(state),
414414
invertCallstack: getInvertCallstack(state),
415415
implementationFilter: getImplementationFilter(state),
416416
// Use the filtered call node max depth, rather than the preview filtered call node

src/components/network-chart/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919

2020
import {
2121
getScrollToSelectionGeneration,
22-
getPreviewSelection,
22+
getPreviewSelectionIsBeingModified,
2323
getPreviewSelectionRange,
2424
} from '../../selectors/profile';
2525
import { selectedThreadSelectors } from '../../selectors/per-thread';
@@ -422,7 +422,7 @@ export const NetworkChart = explicitConnect<
422422
hoveredMarkerIndexFromState:
423423
selectedThreadSelectors.getHoveredMarkerIndex(state),
424424
timeRange: getPreviewSelectionRange(state),
425-
disableOverscan: getPreviewSelection(state).isModifying,
425+
disableOverscan: getPreviewSelectionIsBeingModified(state),
426426
threadsKey: getSelectedThreadsKey(state),
427427
}),
428428
mapDispatchToProps: {

src/components/timeline/Markers.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Tooltip } from 'firefox-profiler/components/tooltip/Tooltip';
1414
import { TooltipMarker } from 'firefox-profiler/components/tooltip/Marker';
1515
import { timeCode } from 'firefox-profiler/utils/time-code';
1616
import explicitConnect from 'firefox-profiler/utils/connect';
17-
import { getPreviewSelection } from 'firefox-profiler/selectors/profile';
17+
import { getPreviewSelectionIsBeingModified } from 'firefox-profiler/selectors/profile';
1818
import { getThreadSelectorsFromThreadsKey } from 'firefox-profiler/selectors/per-thread';
1919
import { getSelectedThreadIndexes } from 'firefox-profiler/selectors/url-state';
2020
import { changeRightClickedMarker } from 'firefox-profiler/actions/profile-view';
@@ -528,7 +528,7 @@ export const TimelineMarkersJank = explicitConnect<
528528
// These don't use marker schema as they are derived.
529529
markerIndexes: selectors.getTimelineJankMarkerIndexes(state),
530530
isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey),
531-
isModifyingSelection: getPreviewSelection(state).isModifying,
531+
isModifyingSelection: getPreviewSelectionIsBeingModified(state),
532532
testId: 'TimelineMarkersJank',
533533
rightClickedMarker: selectors.getRightClickedMarker(state),
534534
};
@@ -557,7 +557,7 @@ export const TimelineMarkersOverview = explicitConnect<
557557
getMarker: selectors.getMarkerGetter(state),
558558
markerIndexes: selectors.getTimelineOverviewMarkerIndexes(state),
559559
isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey),
560-
isModifyingSelection: getPreviewSelection(state).isModifying,
560+
isModifyingSelection: getPreviewSelectionIsBeingModified(state),
561561
testId: 'TimelineMarkersOverview',
562562
rightClickedMarker: selectors.getRightClickedMarker(state),
563563
};
@@ -583,7 +583,7 @@ export const TimelineMarkersFileIo = explicitConnect<
583583
getMarker: selectors.getMarkerGetter(state),
584584
markerIndexes: selectors.getTimelineFileIoMarkerIndexes(state),
585585
isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey),
586-
isModifyingSelection: getPreviewSelection(state).isModifying,
586+
isModifyingSelection: getPreviewSelectionIsBeingModified(state),
587587
testId: 'TimelineMarkersFileIo',
588588
rightClickedMarker: selectors.getRightClickedMarker(state),
589589
};
@@ -609,7 +609,7 @@ export const TimelineMarkersMemory = explicitConnect<
609609
getMarker: selectors.getMarkerGetter(state),
610610
markerIndexes: selectors.getTimelineMemoryMarkerIndexes(state),
611611
isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey),
612-
isModifyingSelection: getPreviewSelection(state).isModifying,
612+
isModifyingSelection: getPreviewSelectionIsBeingModified(state),
613613
additionalClassName: 'timelineMarkersMemory',
614614
testId: 'TimelineMarkersMemory',
615615
rightClickedMarker: selectors.getRightClickedMarker(state),
@@ -636,7 +636,7 @@ export const TimelineMarkersIPC = explicitConnect<
636636
getMarker: selectors.getMarkerGetter(state),
637637
markerIndexes: selectors.getTimelineIPCMarkerIndexes(state),
638638
isSelected: _getTimelineMarkersIsSelected(selectedThreads, threadsKey),
639-
isModifyingSelection: getPreviewSelection(state).isModifying,
639+
isModifyingSelection: getPreviewSelectionIsBeingModified(state),
640640
additionalClassName: 'timelineMarkersIPC',
641641
testId: 'TimelineMarkersIPC',
642642
rightClickedMarker: selectors.getRightClickedMarker(state),

src/components/timeline/TrackNetwork.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
getCommittedRange,
1515
getZeroAt,
1616
getInnerWindowIDToPageMap,
17-
getPreviewSelection,
17+
getPreviewSelectionIsBeingModified,
1818
} from 'firefox-profiler/selectors/profile';
1919
import { getThreadSelectors } from 'firefox-profiler/selectors/per-thread';
2020
import {
@@ -432,7 +432,7 @@ export const TrackNetwork = explicitConnect<
432432
rangeStart: start,
433433
rangeEnd: end,
434434
zeroAt: getZeroAt(state),
435-
isModifyingSelection: getPreviewSelection(state).isModifying,
435+
isModifyingSelection: getPreviewSelectionIsBeingModified(state),
436436
verticalMarkerIndexes: selectors.getTimelineVerticalMarkerIndexes(state),
437437
rightClickedMarkerIndex: selectors.getRightClickedMarkerIndex(state),
438438
selectedNetworkMarkerIndex:

src/components/timeline/TrackScreenshots.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { PureComponent } from 'react';
66
import explicitConnect from 'firefox-profiler/utils/connect';
77
import {
88
getCommittedRange,
9-
getPreviewSelection,
9+
getPreviewSelectionIsBeingModified,
1010
} from 'firefox-profiler/selectors/profile';
1111
import { getThreadSelectors } from 'firefox-profiler/selectors/per-thread';
1212
import {
@@ -190,7 +190,6 @@ export const TimelineTrackScreenshots = explicitConnect<
190190
const { threadIndex, windowId } = ownProps;
191191
const selectors = getThreadSelectors(threadIndex);
192192
const { start, end } = getCommittedRange(state);
193-
const previewSelection = getPreviewSelection(state);
194193
return {
195194
thread: selectors.getRangeFilteredThread(state),
196195
screenshots:
@@ -199,8 +198,7 @@ export const TimelineTrackScreenshots = explicitConnect<
199198
threadName: selectors.getFriendlyThreadName(state),
200199
rangeStart: start,
201200
rangeEnd: end,
202-
isMakingPreviewSelection:
203-
previewSelection.hasSelection && previewSelection.isModifying,
201+
isMakingPreviewSelection: getPreviewSelectionIsBeingModified(state),
204202
};
205203
},
206204
mapDispatchToProps: {

src/selectors/profile.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export const getTableViewOptionSelectors: (
140140
export const getPreviewSelection: Selector<PreviewSelection> = (state) =>
141141
getProfileViewOptions(state).previewSelection;
142142

143+
export const getPreviewSelectionIsBeingModified: Selector<boolean> = (
144+
state
145+
) => {
146+
return getPreviewSelection(state).isModifying;
147+
};
148+
143149
/**
144150
* This selector returns the current range, taking into account the current
145151
* preview selection if any.

0 commit comments

Comments
 (0)