File tree Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export interface StudyVm {
25
25
loading : boolean ;
26
26
nextChapterId ?: ChapterId ;
27
27
justSetChapterId ?: ChapterId ;
28
+ nextPly ?: number ;
28
29
tab : Prop < Tab > ;
29
30
toolTab : Prop < ToolTab > ;
30
31
chapterId : ChapterId ;
Original file line number Diff line number Diff line change @@ -32,24 +32,15 @@ export function broadcastChatHandler(ctrl: AnalyseCtrl): BroadcastChatHandler {
32
32
const segs = msg . split ( separator ) ;
33
33
if ( segs . length == 3 ) {
34
34
const [ _ , chapterId , ply ] = segs ;
35
- ctrl . study . setChapter ( chapterId ) ;
36
-
37
- let attempts = 0 ;
38
- const maxAttempts = 50 ;
39
-
40
- // wait for the chapter to be set before jumping to the move
41
- const waitForLoadingAndJump = ( ) => {
42
- if ( ! ctrl . study ?. vm . loading ) {
43
- ctrl . jumpToMain ( parseInt ( ply ) ) ;
44
- } else if ( attempts < maxAttempts ) {
45
- attempts ++ ;
46
- setTimeout ( waitForLoadingAndJump , 100 ) ;
47
- } else {
48
- console . log ( 'Failed to jump to move, took too many attempts.' ) ;
35
+ if ( ctrl . study . vm . chapterId != chapterId || ctrl . study . vm . loading ) {
36
+ ctrl . study . vm . nextPly = parseInt ( ply ) ;
37
+ ctrl . study . setChapter ( chapterId ) ;
38
+ } else {
39
+ if ( ctrl . study . relay . tourShow ( ) ) {
40
+ ctrl . study . relay . tourShow ( false ) ;
49
41
}
50
- } ;
51
-
52
- waitForLoadingAndJump ( ) ;
42
+ ctrl . jumpToMain ( parseInt ( ply ) ) ;
43
+ }
53
44
}
54
45
}
55
46
} ;
Original file line number Diff line number Diff line change @@ -364,8 +364,13 @@ export default class StudyCtrl {
364
364
: this . data . chapter . relayPath || this . chapters . localPaths [ this . vm . chapterId ] || treePath . root ;
365
365
}
366
366
367
- // path could be gone (because of subtree deletion), go as far as possible
368
- this . ctrl . userJump ( this . ctrl . tree . longestValidPath ( nextPath ) ) ;
367
+ if ( this . vm . nextPly ) {
368
+ this . ctrl . jumpToMain ( this . vm . nextPly ) ;
369
+ this . vm . nextPly = undefined ;
370
+ } else {
371
+ // path could be gone (because of subtree deletion), go as far as possible
372
+ this . ctrl . userJump ( this . ctrl . tree . longestValidPath ( nextPath ) ) ;
373
+ }
369
374
370
375
this . vm . justSetChapterId = undefined ;
371
376
You can’t perform that action at this time.
0 commit comments