@@ -118,12 +118,11 @@ export class TimeTravelActions extends CodeEditorActions<TimeTravelState> {
118118 } ;
119119
120120 private init_syncdoc = async ( ) : Promise < void > => {
121- let mainFileActions : any = null ;
122121 await until ( async ( ) => {
123122 if ( this . isClosed ( ) ) {
124123 return true ;
125124 }
126- mainFileActions = this . redux . getEditorActions (
125+ const mainFileActions = this . redux . getEditorActions (
127126 this . project_id ,
128127 this . docpath ,
129128 ) ;
@@ -138,29 +137,28 @@ export class TimeTravelActions extends CodeEditorActions<TimeTravelState> {
138137 // will try again above in the next loop
139138 return false ;
140139 } else {
141- const doc = mainFileActions . _syncstring ;
140+ const doc = getSyncDocFromEditorActions ( mainFileActions ) ;
142141 if ( doc == null || doc . get_state ( ) == "closed" ) {
143- // file is closing
142+ // file maybe closing
144143 return false ;
145144 }
146145 // got it!
146+ this . syncdoc = doc ;
147147 return true ;
148148 }
149149 } ) ;
150- if ( this . isClosed ( ) || mainFileActions == null ) {
150+ if ( this . isClosed ( ) || ! this . syncdoc ) {
151151 return ;
152152 }
153- this . syncdoc = mainFileActions . _syncstring ;
154153
155154 if (
156- this . syncdoc == null ||
157155 this . syncdoc . get_state ( ) == "closed" ||
158156 // @ts -ignore
159157 this . syncdoc . is_fake
160158 ) {
161159 return ;
162160 }
163- if ( this . syncdoc . get_state ( ) != "ready ") {
161+ if ( this . syncdoc . get_state ( ) == "init ") {
164162 try {
165163 await once ( this . syncdoc , "ready" ) ;
166164 } catch {
@@ -516,3 +514,10 @@ function isProjectOldEnoughToHaveLegacyHistory({
516514 . getIn ( [ "project_map" , project_id , "created" ] ) ;
517515 return created == null || created <= LEGACY_CUTOFF ;
518516}
517+
518+ function getSyncDocFromEditorActions ( actions ) {
519+ if ( actions . path . endsWith ( ".course" ) ) {
520+ return actions . course_actions . syncdb ;
521+ }
522+ return actions . _syncstring ;
523+ }
0 commit comments