@@ -97,7 +97,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
9797 if ( chapterId && chapterId != this . currentChapter ) {
9898 this . loaded = false ;
9999 this . refreshIcon = 'spinner' ;
100- this . loadChapter ( chapterId ) ;
100+ this . loadChapter ( chapterId , true ) ;
101101 }
102102 }
103103
@@ -162,7 +162,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
162162 }
163163
164164 // Show chapter.
165- return this . loadChapter ( this . currentChapter ) . then ( ( ) => {
165+ return this . loadChapter ( this . currentChapter , refresh ) . then ( ( ) => {
166166 if ( downloadFailed && this . appProvider . isOnline ( ) ) {
167167 // We could load the main file but the download failed. Show error message.
168168 this . showErrorDownloadingSomeFiles ( downloadFailError ) ;
@@ -179,9 +179,10 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
179179 * Load a book chapter.
180180 *
181181 * @param chapterId Chapter to load.
182+ * @param logChapterId Whether chapter ID should be passed to the log view function.
182183 * @return Promise resolved when done.
183184 */
184- protected loadChapter ( chapterId : string ) : Promise < void > {
185+ protected loadChapter ( chapterId : string , logChapterId : boolean ) : Promise < void > {
185186 this . currentChapter = chapterId ;
186187 this . domUtils . scrollToTop ( this . content ) ;
187188
@@ -191,7 +192,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
191192 this . nextChapter = this . bookProvider . getNextChapter ( this . chapters , chapterId ) ;
192193
193194 // Chapter loaded, log view. We don't return the promise because we don't want to block the user for this.
194- this . bookProvider . logView ( this . module . instance , chapterId , this . module . name ) . then ( ( ) => {
195+ this . bookProvider . logView ( this . module . instance , logChapterId ? chapterId : undefined , this . module . name ) . then ( ( ) => {
195196 // Module is completed when last chapter is viewed, so we only check completion if the last is reached.
196197 if ( this . nextChapter == '0' ) {
197198 this . courseProvider . checkModuleCompletion ( this . courseId , this . module . completiondata ) ;
0 commit comments