MOBILE-4081 wiki: Remove non-null assertions in index page
parent
32d1e0761b
commit
2c20a24f84
|
@ -327,8 +327,8 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
|
|
||||||
await this.showLoadingAndFetch(true, false);
|
await this.showLoadingAndFetch(true, false);
|
||||||
|
|
||||||
if (this.currentPage) {
|
if (this.currentPage && this.wiki) {
|
||||||
CoreUtils.ignoreErrors(AddonModWiki.logPageView(this.currentPage, this.wiki!.id, this.wiki!.name));
|
CoreUtils.ignoreErrors(AddonModWiki.logPageView(this.currentPage, this.wiki.id, this.wiki.name));
|
||||||
}
|
}
|
||||||
}, CoreSites.getCurrentSiteId());
|
}, CoreSites.getCurrentSiteId());
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
|
|
||||||
// If no page specified, search page title in the offline pages.
|
// If no page specified, search page title in the offline pages.
|
||||||
if (!this.currentPage) {
|
if (!this.currentPage) {
|
||||||
const searchTitle = this.pageTitle ? this.pageTitle : this.wiki!.firstpagetitle;
|
const searchTitle = this.pageTitle ? this.pageTitle : this.wiki?.firstpagetitle ?? '';
|
||||||
const pageExists = dbPages.some((page) => page.title == searchTitle);
|
const pageExists = dbPages.some((page) => page.title == searchTitle);
|
||||||
|
|
||||||
if (pageExists) {
|
if (pageExists) {
|
||||||
|
@ -482,7 +482,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
`${AddonModWikiModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
|
`${AddonModWikiModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
pageTitle: this.wiki!.firstpagetitle,
|
pageTitle: this.wiki?.firstpagetitle ?? '',
|
||||||
wikiId: this.currentSubwiki?.wikiid,
|
wikiId: this.currentSubwiki?.wikiid,
|
||||||
userId: this.currentSubwiki?.userid,
|
userId: this.currentSubwiki?.userid,
|
||||||
groupId: this.currentSubwiki?.groupid,
|
groupId: this.currentSubwiki?.groupid,
|
||||||
|
@ -640,9 +640,11 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
* @param groupId Group ID of the subwiki.
|
* @param groupId Group ID of the subwiki.
|
||||||
*/
|
*/
|
||||||
goToSubwiki(subwikiId: number, userId: number, groupId: number): void {
|
goToSubwiki(subwikiId: number, userId: number, groupId: number): void {
|
||||||
if (subwikiId != this.currentSubwiki!.id || userId != this.currentSubwiki!.userid ||
|
if (
|
||||||
groupId != this.currentSubwiki!.groupid) {
|
subwikiId !== this.currentSubwiki?.id ||
|
||||||
|
userId !== this.currentSubwiki?.userid ||
|
||||||
|
groupId !== this.currentSubwiki?.groupid
|
||||||
|
) {
|
||||||
this.openPageOrSubwiki({
|
this.openPageOrSubwiki({
|
||||||
subwikiId: subwikiId,
|
subwikiId: subwikiId,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
@ -710,13 +712,17 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
* @param result Data returned on the sync function.
|
* @param result Data returned on the sync function.
|
||||||
* @return If suceed or not.
|
* @return If suceed or not.
|
||||||
*/
|
*/
|
||||||
protected hasSyncSucceed(result: AddonModWikiSyncWikiResult): boolean {
|
protected hasSyncSucceed(result: AddonModWikiSyncWikiResult | undefined): boolean {
|
||||||
if (result.updated) {
|
if (!result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.updated && this.wiki) {
|
||||||
// Trigger event.
|
// Trigger event.
|
||||||
this.ignoreManualSyncEvent = true;
|
this.ignoreManualSyncEvent = true;
|
||||||
CoreEvents.trigger(AddonModWikiSyncProvider.MANUAL_SYNCED, {
|
CoreEvents.trigger(AddonModWikiSyncProvider.MANUAL_SYNCED, {
|
||||||
...result,
|
...result,
|
||||||
wikiId: this.wiki!.id,
|
wikiId: this.wiki.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,8 +847,12 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
*
|
*
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected sync(): Promise<AddonModWikiSyncWikiResult> {
|
protected async sync(): Promise<AddonModWikiSyncWikiResult | undefined> {
|
||||||
return AddonModWikiSync.syncWiki(this.wiki!.id, this.courseId, this.wiki!.coursemodule);
|
if (!this.wiki) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AddonModWikiSync.syncWiki(this.wiki.id, this.courseId, this.wiki.coursemodule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1063,14 +1073,16 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
this.subwikiData.subwikis.push({ label: '', subwikis: subwikiList });
|
this.subwikiData.subwikis.push({ label: '', subwikis: subwikiList });
|
||||||
}
|
}
|
||||||
|
|
||||||
AddonModWiki.setSubwikiList(
|
if (this.wiki) {
|
||||||
this.wiki!.id,
|
AddonModWiki.setSubwikiList(
|
||||||
this.subwikiData.subwikis,
|
this.wiki.id,
|
||||||
this.subwikiData.count,
|
this.subwikiData.subwikis,
|
||||||
this.subwikiData.subwikiSelected,
|
this.subwikiData.count,
|
||||||
this.subwikiData.userSelected,
|
this.subwikiData.subwikiSelected,
|
||||||
this.subwikiData.groupSelected,
|
this.subwikiData.userSelected,
|
||||||
);
|
this.subwikiData.groupSelected,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue