@@ -233,7 +233,7 @@ export const createComment: AsyncAction = async ({ state, effects }) => {
233233 )
234234 : '' ,
235235 path : state . editor . currentModule . path ,
236- sandboxVersion : sandbox . version ,
236+ updatedAt : state . editor . currentModule . updatedAt ,
237237 } ;
238238 }
239239
@@ -522,25 +522,19 @@ export const onCommentAdded: Action<CommentAddedSubscription> = (
522522 const module = sandbox . modules . find (
523523 moduleItem => moduleItem . path === codeReference . path
524524 ) ;
525- // We do a check here to catch if our assumption was wrong on always having the updated file
526- // when receiving a comment update
527- if ( sandbox . version === codeReference . sandboxVersion ) {
528- // We create a diff operation which is applied to the comment to ensure
529- // any operations received in the meantime is applied
530- const diffOperation = getTextOperation ( module . savedCode , module . code ) ;
531- const range = new Selection . Range (
532- codeReference . anchor ,
533- codeReference . head
534- ) ;
535- const newRange = range . transform ( diffOperation ) ;
536525
537- codeReference . anchor = newRange . anchor ;
538- codeReference . head = newRange . head ;
539- } else {
540- captureException (
541- new Error ( 'Received comment add update before file was updated' )
542- ) ;
526+ if ( ! module ) {
527+ return ;
543528 }
529+
530+ // We create a diff operation which is applied to the comment to ensure
531+ // any operations received in the meantime is applied
532+ const diffOperation = getTextOperation ( module . savedCode , module . code ) ;
533+ const range = new Selection . Range ( codeReference . anchor , codeReference . head ) ;
534+ const newRange = range . transform ( diffOperation ) ;
535+
536+ codeReference . anchor = newRange . anchor ;
537+ codeReference . head = newRange . head ;
544538 }
545539
546540 state . comments . comments [ comment . sandbox . id ] [ comment . id ] = comment ;
0 commit comments