@@ -1488,21 +1488,23 @@ export const updateComment: AsyncAction<{
14881488 const sandboxId = state . editor . currentSandbox . id ;
14891489 const isResolved = state . editor . comments [ sandboxId ] [ id ] . isResolved ;
14901490 const comment = state . editor . comments [ sandboxId ] [ id ] . originalMessage . content ;
1491+ const currentComment = state . editor . currentComment ;
14911492 const updateIsCurrent =
1492- state . editor . comments [ sandboxId ] [ id ] . id === state . editor . currentComment . id ;
1493+ currentComment &&
1494+ state . editor . comments [ sandboxId ] [ id ] . id === currentComment . id ;
14931495
14941496 if ( 'isResolved' in data ) {
14951497 state . editor . comments [ sandboxId ] [ id ] . isResolved = data . isResolved ;
1496- if ( updateIsCurrent ) {
1497- state . editor . currentComment . isResolved = data . isResolved ;
1498+ if ( updateIsCurrent && currentComment ) {
1499+ currentComment . isResolved = data . isResolved ;
14981500 }
14991501 }
15001502
15011503 if ( 'comment' in data ) {
15021504 state . editor . comments [ sandboxId ] [ id ] . originalMessage . content = data . comment ;
15031505
1504- if ( updateIsCurrent ) {
1505- state . editor . currentComment . originalMessage . content = data . comment ;
1506+ if ( updateIsCurrent && currentComment ) {
1507+ currentComment . originalMessage . content = data . comment ;
15061508 }
15071509 }
15081510
@@ -1517,9 +1519,9 @@ export const updateComment: AsyncAction<{
15171519 ) ;
15181520 state . editor . comments [ sandboxId ] [ id ] . isResolved = isResolved ;
15191521 state . editor . comments [ sandboxId ] [ id ] . originalMessage . content = comment ;
1520- if ( updateIsCurrent ) {
1521- state . editor . currentComment . id = id ;
1522- state . editor . currentComment . originalMessage . content = comment ;
1522+ if ( updateIsCurrent && currentComment ) {
1523+ currentComment . id = id ;
1524+ currentComment . originalMessage . content = comment ;
15231525 }
15241526 }
15251527} ;
0 commit comments