import { useMemo } from 'react' import Container from './container' import Toolbar from './toolbar/toolbar' import Nav from './nav' import Toggler from './toggler' import ChangeEntry from './entries/change-entry' import AggregateChangeEntry from './entries/aggregate-change-entry' import CommentEntry from './entries/comment-entry' import AddCommentEntry from './entries/add-comment-entry' import BulkActionsEntry from './entries/bulk-actions-entry/bulk-actions-entry' import PositionedEntries from './positioned-entries' import { useReviewPanelValueContext } from '../../context/review-panel/review-panel-context' import useCodeMirrorContentHeight from '../../hooks/use-codemirror-content-height' import { ReviewPanelEntry } from '../../../../../../types/review-panel/entry' import { ReviewPanelDocEntries, ThreadId, } from '../../../../../../types/review-panel/review-panel' const isEntryAThreadId = ( entry: keyof ReviewPanelDocEntries ): entry is ThreadId => entry !== 'add-comment' && entry !== 'bulk-actions' function CurrentFileContainer() { const { commentThreads, entries, openDocId, permissions, loadingThreads, users, entryHover, nVisibleSelectedChanges: nChanges, } = useReviewPanelValueContext() const contentHeight = useCodeMirrorContentHeight() const currentDocEntries = openDocId && openDocId in entries ? entries[openDocId] : undefined const objectEntries = useMemo(() => { return Object.entries(currentDocEntries || {}) as Array< [keyof ReviewPanelDocEntries, ReviewPanelEntry] > }, [currentDocEntries]) return (
{openDocId && objectEntries.map(([id, entry]) => { if (!entry.visible) { return null } if ( isEntryAThreadId(id) && (entry.type === 'insert' || entry.type === 'delete') ) { return ( ) } if (isEntryAThreadId(id) && entry.type === 'aggregate-change') { return ( ) } if ( isEntryAThreadId(id) && entry.type === 'comment' && !loadingThreads ) { return ( ) } if (entry.type === 'add-comment' && permissions.comment) { return } if (entry.type === 'bulk-actions') { return ( ) } return null })}
) } export default CurrentFileContainer