@@ -118,12 +118,11 @@ export class TimeTravelActions extends CodeEditorActions<TimeTravelState> {
118
118
} ;
119
119
120
120
private init_syncdoc = async ( ) : Promise < void > => {
121
- let mainFileActions : any = null ;
122
121
await until ( async ( ) => {
123
122
if ( this . isClosed ( ) ) {
124
123
return true ;
125
124
}
126
- mainFileActions = this . redux . getEditorActions (
125
+ const mainFileActions = this . redux . getEditorActions (
127
126
this . project_id ,
128
127
this . docpath ,
129
128
) ;
@@ -138,29 +137,28 @@ export class TimeTravelActions extends CodeEditorActions<TimeTravelState> {
138
137
// will try again above in the next loop
139
138
return false ;
140
139
} else {
141
- const doc = mainFileActions . _syncstring ;
140
+ const doc = getSyncDocFromEditorActions ( mainFileActions ) ;
142
141
if ( doc == null || doc . get_state ( ) == "closed" ) {
143
- // file is closing
142
+ // file maybe closing
144
143
return false ;
145
144
}
146
145
// got it!
146
+ this . syncdoc = doc ;
147
147
return true ;
148
148
}
149
149
} ) ;
150
- if ( this . isClosed ( ) || mainFileActions == null ) {
150
+ if ( this . isClosed ( ) || ! this . syncdoc ) {
151
151
return ;
152
152
}
153
- this . syncdoc = mainFileActions . _syncstring ;
154
153
155
154
if (
156
- this . syncdoc == null ||
157
155
this . syncdoc . get_state ( ) == "closed" ||
158
156
// @ts -ignore
159
157
this . syncdoc . is_fake
160
158
) {
161
159
return ;
162
160
}
163
- if ( this . syncdoc . get_state ( ) != "ready ") {
161
+ if ( this . syncdoc . get_state ( ) == "init ") {
164
162
try {
165
163
await once ( this . syncdoc , "ready" ) ;
166
164
} catch {
@@ -516,3 +514,10 @@ function isProjectOldEnoughToHaveLegacyHistory({
516
514
. getIn ( [ "project_map" , project_id , "created" ] ) ;
517
515
return created == null || created <= LEGACY_CUTOFF ;
518
516
}
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