@@ -70,6 +70,8 @@ $(document).on('turbolinks:load', function () {
7070 setAnnotations ( currentEditor , $ ( editor ) . data ( 'file-id' ) ) ;
7171 currentEditor . on ( "guttermousedown" , handleSidebarClick ) ;
7272 currentEditor . on ( "guttermousemove" , showPopover ) ;
73+ currentEditor . getSession ( ) . setOption ( "useWorker" , false ) ;
74+
7375 } ) ;
7476
7577 const handleAceThemeChangeEvent = function ( ) {
@@ -140,33 +142,22 @@ $(document).on('turbolinks:load', function () {
140142
141143 function setAnnotations ( editor , fileid ) {
142144 const session = editor . getSession ( ) ;
143- let customAnnotations = [ ] ;
144- $ . ajax ( {
145+
146+ const jqrequest = $ . ajax ( {
145147 dataType : 'json' ,
146148 method : 'GET' ,
147149 url : Routes . comments_path ( ) ,
148- data : { file_id : fileid }
149- } ) . done ( function ( response ) {
150+ data : {
151+ file_id : fileid
152+ }
153+ } ) ;
154+
155+ jqrequest . done ( function ( response ) {
150156 $ . each ( response , function ( index , comment ) {
151157 comment . className = 'code-ocean_comment' ;
152- comment . type = 'info' ; // Required for proper rendering
153-
154- comment . custom = true ;
158+ comment . type = 'info' ; // Required for the annotation to be rendered correctly (besides being hidden through CSS).
155159 } ) ;
156-
157- customAnnotations . length = 0 ; // Clear previous custom annotations
158- customAnnotations . push ( ...response ) ;
159- mergeAnnotations ( ) ;
160- } ) ;
161-
162- function mergeAnnotations ( ) {
163- let existingAnnotations = session . getAnnotations ( ) . filter ( ann => ! ann . custom ) ;
164- session . setAnnotations ( [ ...existingAnnotations , ...customAnnotations ] ) ;
165- }
166-
167- // Ensure annotations are not overridden
168- session . on ( 'changeAnnotation' , function ( ) {
169- mergeAnnotations ( ) ;
160+ session . setAnnotations ( response ) ;
170161 } ) ;
171162 }
172163
0 commit comments