MOBILE-3980 book: Log book viewed in entry page
parent
7f34da3462
commit
328b39a541
|
@ -18,6 +18,7 @@ import { AddonModBook, AddonModBookBookWSData, AddonModBookNumbering, AddonModBo
|
||||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||||
import { CoreCourse } from '@features/course/services/course';
|
import { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a book entry page.
|
* Component that displays a book entry page.
|
||||||
|
@ -47,6 +48,9 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
|
||||||
this.loadContent();
|
this.loadContent();
|
||||||
|
|
||||||
|
// Log book viewed.
|
||||||
|
await CoreUtils.ignoreErrors(AddonModBook.logView(this.module.instance, undefined, this.module.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,7 +69,6 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
|
||||||
protected firstLoad = true;
|
|
||||||
protected managerUnsubscribe?: () => void;
|
protected managerUnsubscribe?: () => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,10 +271,6 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async onChapterViewed(chapterId: number): Promise<void> {
|
protected async onChapterViewed(chapterId: number): Promise<void> {
|
||||||
// Don't log the chapter ID when the user has just opened the book.
|
|
||||||
const logChapterId = this.firstLoad;
|
|
||||||
this.firstLoad = false;
|
|
||||||
|
|
||||||
if (this.displayNavBar) {
|
if (this.displayNavBar) {
|
||||||
this.navigationItems = this.getNavigationItems(chapterId);
|
this.navigationItems = this.getNavigationItems(chapterId);
|
||||||
}
|
}
|
||||||
|
@ -289,11 +284,7 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chapter loaded, log view.
|
// Chapter loaded, log view.
|
||||||
await CoreUtils.ignoreErrors(AddonModBook.logView(
|
await CoreUtils.ignoreErrors(AddonModBook.logView(this.module.instance, chapterId, this.module.name));
|
||||||
this.module.instance,
|
|
||||||
logChapterId ? chapterId : undefined,
|
|
||||||
this.module.name,
|
|
||||||
));
|
|
||||||
|
|
||||||
const currentChapterIndex = this.chapters.findIndex((chapter) => chapter.id == chapterId);
|
const currentChapterIndex = this.chapters.findIndex((chapter) => chapter.id == chapterId);
|
||||||
const isLastChapter = currentChapterIndex < 0 || this.chapters[currentChapterIndex + 1] === undefined;
|
const isLastChapter = currentChapterIndex < 0 || this.chapters[currentChapterIndex + 1] === undefined;
|
||||||
|
|
Loading…
Reference in New Issue