// @flow import React, {Fragment, useContext} from 'react'; import {ProfilerContext} from './ProfilerContext'; import {formatDuration, formatTime} from './utils'; import {StoreContext} from '../context'; import {getGradientColor} from './utils'; import styles from './SidebarInteractions.css'; export type Props = {||}; export default function SidebarInteractions(_: Props) { const { selectedInteractionID, rootID, selectCommitIndex, selectTab, } = useContext(ProfilerContext); const {profilerStore} = useContext(StoreContext); const {profilingCache} = profilerStore; if (selectedInteractionID === null) { return
Nothing selected
; } const {interactionCommits, interactions} = profilerStore.getDataForRoot( ((rootID: any): number), ); const interaction = interactions.get(selectedInteractionID); if (interaction == null) { throw Error( `Could not find interaction by selected interaction id "${selectedInteractionID}"`, ); } const {maxCommitDuration} = profilingCache.getInteractionsChartData({ rootID: ((rootID: any): number), }); const viewCommit = (commitIndex: number) => { selectTab('flame-chart'); selectCommitIndex(commitIndex); }; const listItems: Array = []; const commitIndices = interactionCommits.get(selectedInteractionID); if (commitIndices != null) { commitIndices.forEach(commitIndex => { const {duration, timestamp} = profilerStore.getCommitData( ((rootID: any): number), commitIndex, ); listItems.push(
  • viewCommit(commitIndex)}>
    timestamp: {formatTime(timestamp)}s
    duration: {formatDuration(duration)}ms
  • , ); }); } return (
    {interaction.name}
    Commits:
      {listItems}
    ); }