Skip to content

Commit 8368b0b

Browse files
authored
Merge pull request #19189 from johndoknjas/chapter-scroll-other-users
When creating/changing the chapter, scroll to it as appropriate for other users
2 parents 8070aef + 0b6c088 commit 8368b0b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ui/analyse/src/study/studyCtrl.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ export default class StudyCtrl {
506506
this.vm.mode.sticky = false;
507507
if (!this.vm.behind) this.vm.behind = 1;
508508
this.vm.chapterId = id;
509+
this.chapters.scroller.request('smooth'); // sticky scroll request is set in `changeChapter`
509510
this.relay?.liveboardPlugin?.reset();
510511
await this.xhrReload(false, () => componentCallbacks(id));
511512
}
@@ -726,8 +727,7 @@ export default class StudyCtrl {
726727
const position = d.p,
727728
who = d.w;
728729
this.setMemberActive(who);
729-
if (this.wrongChapter(d)) return;
730-
if (who && who.s === site.sri) return;
730+
if (this.wrongChapter(d) || (who && who.s === site.sri)) return;
731731
if (!this.ctrl.tree.pathExists(d.p.path)) return this.xhrReload();
732732
this.ctrl.tree.promoteAt(position.path, d.toMainline);
733733
if (this.vm.mode.sticky) this.ctrl.jump(this.ctrl.path);
@@ -740,10 +740,14 @@ export default class StudyCtrl {
740740
},
741741
changeChapter: d => {
742742
this.setMemberActive(d.w);
743-
if (!this.vm.mode.sticky) this.vm.behind++;
744743
this.data.position = d.p;
745-
if (this.vm.mode.sticky) this.xhrReload();
746-
else this.redraw();
744+
if (this.vm.mode.sticky) {
745+
this.chapters.scroller.request('smooth'); // non-sticky scroll request is set in `setChapter`
746+
this.xhrReload();
747+
} else {
748+
this.vm.behind++;
749+
this.redraw();
750+
}
747751
},
748752
updateChapter: d => {
749753
this.setMemberActive(d.w);
@@ -779,7 +783,7 @@ export default class StudyCtrl {
779783
this.vm.chapterId = d.p.chapterId;
780784
this.vm.nextChapterId = d.p.chapterId;
781785
this.chapters.scroller.request('instant');
782-
}
786+
} else this.chapters.scroller.request('smooth');
783787
this.xhrReload(true);
784788
},
785789
members: d => {

0 commit comments

Comments
 (0)