Merge pull request #20728 from overleaf/dp-state-field-error

Safeguard against addCommentStateField not existing

GitOrigin-RevId: 06f5f72bc12552b9668892a50d9789d6dfc45a9e
This commit is contained in:
David 2024-10-02 12:57:38 +01:00 committed by Copybot
parent aba4694377
commit df2e3c1119

View file

@ -147,7 +147,7 @@ const ReviewPanelCurrentFile: FC = () => {
const positionsRef = useRef<Map<string, number>>(new Map())
const addCommentRanges = state.field(addCommentStateField).ranges
const addCommentRanges = state.field(addCommentStateField, false)?.ranges
useEffect(() => {
if (aggregatedRanges) {
@ -178,6 +178,10 @@ const ReviewPanelCurrentFile: FC = () => {
}
}
if (!addCommentRanges) {
return
}
const cursor = addCommentRanges.iter()
while (cursor.value) {
@ -212,6 +216,10 @@ const ReviewPanelCurrentFile: FC = () => {
)
const addCommentEntries = useMemo(() => {
if (!addCommentRanges) {
return []
}
const cursor = addCommentRanges.iter()
const entries = []