Merge pull request #2825 from dpalou/MOBILE-3320

Mobile 3320
main
Pau Ferrer Ocaña 2021-06-11 12:29:19 +02:00 committed by GitHub
commit ee3bf7c2e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 151 additions and 143 deletions

View File

@ -40,6 +40,7 @@ export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandl
*/ */
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData { getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData {
const linkParams: Params = contextLevel == 'course' ? { courseId: instanceId } : {}; const linkParams: Params = contextLevel == 'course' ? { courseId: instanceId } : {};
linkParams.upcoming = true;
return { return {
title: 'addon.block_calendarupcoming.pluginname', title: 'addon.block_calendarupcoming.pluginname',

View File

@ -21,10 +21,14 @@ import { CoreCommentsComponentsModule } from '@features/comments/components/comp
import { CoreTagComponentsModule } from '@features/tag/components/components.module'; import { CoreTagComponentsModule } from '@features/tag/components/components.module';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonBlogMainMenuHandlerService } from './services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes { function buildRoutes(injector: Injector): Routes {
return [ return [
...buildTabMainRoutes(injector, { ...buildTabMainRoutes(injector, {
data: {
mainMenuTabRoot: AddonBlogMainMenuHandlerService.PAGE_NAME,
},
component: AddonBlogEntriesPage, component: AddonBlogEntriesPage,
}), }),
]; ];

View File

@ -16,6 +16,7 @@ import { Injector, NgModule } from '@angular/core';
import { Route, RouterModule, ROUTES, Routes } from '@angular/router'; import { Route, RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonCalendarMainMenuHandlerService } from './services/handlers/mainmenu';
export const AddonCalendarEditRoute: Route = { export const AddonCalendarEditRoute: Route = {
path: 'edit/:eventId', path: 'edit/:eventId',
@ -33,14 +34,14 @@ function buildRoutes(injector: Injector): Routes {
{ {
path: 'index', path: 'index',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonCalendarMainMenuHandlerService.PAGE_NAME,
}, },
loadChildren: () => import('@/addons/calendar/pages/index/index.module').then(m => m.AddonCalendarIndexPageModule), loadChildren: () => import('@/addons/calendar/pages/index/index.module').then(m => m.AddonCalendarIndexPageModule),
}, },
{ {
path: 'list', path: 'list',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonCalendarMainMenuHandlerService.PAGE_NAME,
}, },
loadChildren: () => import('@/addons/calendar/pages/list/list.module').then(m => m.AddonCalendarListPageModule), loadChildren: () => import('@/addons/calendar/pages/list/list.module').then(m => m.AddonCalendarListPageModule),
}, },

View File

@ -25,11 +25,15 @@ import { AddonCompetencyCompetencyPage } from './pages/competency/competency';
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary'; import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary';
import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page'; import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page';
import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module'; import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module';
import { AddonCompetencyMainMenuHandlerService } from './services/handlers/mainmenu';
const mobileRoutes: Routes = [ const mobileRoutes: Routes = [
{ {
path: '', path: '',
pathMatch: 'full', pathMatch: 'full',
data: {
mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
},
component: AddonCompetencyPlanListPage, component: AddonCompetencyPlanListPage,
}, },
{ {
@ -75,6 +79,9 @@ const tabletRoutes: Routes = [
}, },
{ {
path: '', path: '',
data: {
mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
},
component: AddonCompetencyPlanListPage, component: AddonCompetencyPlanListPage,
children: [ children: [
{ {

View File

@ -22,12 +22,13 @@ import { CoreSharedModule } from '@/core/shared.module';
import { CoreSearchComponentsModule } from '@features/search/components/components.module'; import { CoreSearchComponentsModule } from '@features/search/components/components.module';
import { AddonMessagesDiscussions35Page } from './discussions.page'; import { AddonMessagesDiscussions35Page } from './discussions.page';
import { AddonMessagesMainMenuHandlerService } from '@addons/messages/services/handlers/mainmenu';
const mobileRoutes: Routes = [ const mobileRoutes: Routes = [
{ {
path: '', path: '',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
}, },
component: AddonMessagesDiscussions35Page, component: AddonMessagesDiscussions35Page,
}, },
@ -38,7 +39,7 @@ const tabletRoutes: Routes = [
{ {
path: '', path: '',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
}, },
component: AddonMessagesDiscussions35Page, component: AddonMessagesDiscussions35Page,
children: [ children: [

View File

@ -21,12 +21,13 @@ import { CoreScreen } from '@services/screen';
import { CoreSharedModule } from '@/core/shared.module'; import { CoreSharedModule } from '@/core/shared.module';
import { AddonMessagesGroupConversationsPage } from './group-conversations.page'; import { AddonMessagesGroupConversationsPage } from './group-conversations.page';
import { AddonMessagesMainMenuHandlerService } from '@addons/messages/services/handlers/mainmenu';
const mobileRoutes: Routes = [ const mobileRoutes: Routes = [
{ {
path: '', path: '',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
}, },
component: AddonMessagesGroupConversationsPage, component: AddonMessagesGroupConversationsPage,
}, },
@ -37,7 +38,7 @@ const tabletRoutes: Routes = [
{ {
path: '', path: '',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
}, },
component: AddonMessagesGroupConversationsPage, component: AddonMessagesGroupConversationsPage,
children: [ children: [

View File

@ -211,13 +211,9 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
} }
/** /**
* Prefetch a module. * @inheritdoc
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @return Promise resolved when done.
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchAssign.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchAssign.bind(this, module, courseId));
} }
@ -226,12 +222,11 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
* *
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchAssign(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { protected async prefetchAssign(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const userId = CoreSites.getCurrentSiteUserId(); const userId = CoreSites.getCurrentSiteUserId();
courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId();
const siteId = CoreSites.getCurrentSiteId();
const options: CoreSitesCommonWSOptions = { const options: CoreSitesCommonWSOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreUser } from '@features/user/services/user'; import { CoreUser } from '@features/user/services/user';
import { CoreGroups } from '@services/groups'; import { CoreGroups } from '@services/groups';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModChat, AddonModChatProvider, AddonModChatSession } from '../chat'; import { AddonModChat, AddonModChatProvider, AddonModChatSession } from '../chat';
@ -64,7 +64,7 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchChat.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchChat.bind(this, module, courseId));
} }
@ -73,10 +73,10 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet
* *
* @param module The module object returned by WS. * @param module The module object returned by WS.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchChat(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { protected async prefetchChat(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
const options = { const options = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId, siteId,

View File

@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreUser } from '@features/user/services/user'; import { CoreUser } from '@features/user/services/user';
import { CoreFilepool } from '@services/filepool'; import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
@ -38,7 +38,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchChoice.bind(this, module, courseId, !!single)); return this.prefetchPackage(module, courseId, this.prefetchChoice.bind(this, module, courseId, !!single));
} }
@ -55,10 +55,8 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number, courseId: number,
single: boolean, single: boolean,
siteId?: string, siteId: string,
): Promise<void> { ): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const commonOptions = { const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId, siteId,

View File

@ -212,7 +212,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchDatabase.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchDatabase.bind(this, module, courseId));
} }
@ -221,12 +221,10 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
* *
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchDatabase(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { protected async prefetchDatabase(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId();
const options = { const options = {
cmId: module.id, cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreFilepool } from '@services/filepool'; import { CoreFilepool } from '@services/filepool';
import { CoreGroups } from '@services/groups'; import { CoreGroups } from '@services/groups';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreTimeUtils } from '@services/utils/time'; import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
@ -122,7 +122,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchFeedback.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchFeedback.bind(this, module, courseId));
} }
@ -131,10 +131,10 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
* *
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchFeedback(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { protected async prefetchFeedback(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
const commonOptions = { const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId, siteId,

View File

@ -171,15 +171,9 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
} }
/** /**
* Prefetch a module. * @inheritdoc
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done.
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchForum.bind(this, module, courseId, single)); return this.prefetchPackage(module, courseId, this.prefetchForum.bind(this, module, courseId, single));
} }

View File

@ -97,7 +97,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchGlossary.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchGlossary.bind(this, module, courseId));
} }
@ -110,8 +110,6 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchGlossary(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> { protected async prefetchGlossary(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const options = { const options = {
cmId: module.id, cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -76,7 +76,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchActivity.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchActivity.bind(this, module, courseId));
} }
@ -91,10 +91,8 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
protected async prefetchActivity( protected async prefetchActivity(
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number, courseId: number,
siteId?: string, siteId: string,
): Promise<void> { ): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const h5pActivity = await AddonModH5PActivity.getH5PActivity(courseId, module.id, { const h5pActivity = await AddonModH5PActivity.getH5PActivity(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId, siteId,

View File

@ -231,17 +231,10 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
} }
/** /**
* Prefetch a module. * @inheritdoc
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done.
*/ */
// eslint-disable-next-line @typescript-eslint/no-unused-vars prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise<void> { return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, !!single));
return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, single));
} }
/** /**
@ -250,12 +243,15 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section. * @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param siteId Site ID.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchLesson(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> { protected async prefetchLesson(
const siteId = CoreSites.getCurrentSiteId(); module: CoreCourseAnyModuleData,
courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId(); courseId: number,
single: boolean,
siteId: string,
): Promise<void> {
const commonOptions = { const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId, siteId,

View File

@ -269,7 +269,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
*/ */
async prefetch( async prefetch(
module: SyncedModule, module: SyncedModule,
courseId?: number, courseId: number,
single?: boolean, single?: boolean,
dirPath?: string, dirPath?: string,
canStart: boolean = true, canStart: boolean = true,
@ -282,9 +282,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
return; return;
} }
const siteId = CoreSites.getCurrentSiteId(); return this.prefetchPackage(module, courseId, this.prefetchQuiz.bind(this, module, courseId, !!single, canStart));
return this.prefetchPackage(module, courseId, this.prefetchQuiz.bind(this, module, courseId, single, siteId, canStart));
} }
/** /**
@ -293,16 +291,16 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section. * @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param siteId Site ID.
* @param canStart If true, start a new attempt if needed. * @param canStart If true, start a new attempt if needed.
* @param siteId Site ID.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchQuiz( protected async prefetchQuiz(
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number, courseId: number,
single: boolean, single: boolean,
siteId: string,
canStart: boolean, canStart: boolean,
siteId: string,
): Promise<void> { ): Promise<void> {
const commonOptions = { const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -47,12 +47,10 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
dirPath?: string, dirPath?: string,
onProgress?: AddonModScormProgressCallback, onProgress?: AddonModScormProgressCallback,
): Promise<void> { ): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.downloadOrPrefetchScorm.bind(this, module, courseId, true, siteId, false, onProgress), this.downloadOrPrefetchScorm.bind(this, module, courseId, true, false, onProgress),
); );
} }
@ -62,18 +60,18 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
* @param module Module. * @param module Module.
* @param courseId Course ID the module belongs to. * @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section. * @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param siteId Site ID.
* @param prefetch True to prefetch, false to download right away. * @param prefetch True to prefetch, false to download right away.
* @param onProgress Function to call on progress. * @param onProgress Function to call on progress.
* @param siteId Site ID.
* @return Promise resolved with the "extra" data to store: the hash of the file. * @return Promise resolved with the "extra" data to store: the hash of the file.
*/ */
protected async downloadOrPrefetchScorm( protected async downloadOrPrefetchScorm(
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number, courseId: number,
single: boolean, single: boolean,
siteId: string,
prefetch: boolean, prefetch: boolean,
onProgress?: AddonModScormProgressCallback, onProgress: AddonModScormProgressCallback | undefined,
siteId: string,
): Promise<string> { ): Promise<string> {
const scorm = await this.getScorm(module, courseId, siteId); const scorm = await this.getScorm(module, courseId, siteId);
@ -370,12 +368,10 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
dirPath?: string, dirPath?: string,
onProgress?: AddonModScormProgressCallback, onProgress?: AddonModScormProgressCallback,
): Promise<void> { ): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.downloadOrPrefetchScorm.bind(this, module, courseId, single, siteId, true, onProgress), this.downloadOrPrefetchScorm.bind(this, module, courseId, single, true, onProgress),
); );
} }

View File

@ -78,8 +78,10 @@
</ng-container> </ng-container>
<!-- Subquestion --> <!-- Subquestion -->
<ng-container *ngIf="question.parent !== 0">
<ion-radio-group [(ngModel)]="answers[question.name]" [required]="question.required" [name]="question.name"> <ion-radio-group [(ngModel)]="answers[question.name]" [required]="question.required" [name]="question.name">
<ion-row *ngIf="question.parent !== 0" class="ion-align-items-center ion-padding-horizontal" [class.even]="isEven"> <ion-row *ngIf="question.parent !== 0" class="ion-align-items-center ion-padding-horizontal"
[class.even]="isEven">
<ion-col size="7"> <ion-col size="7">
<ion-label id="addon-mod_survey-{{question.id}}"> <ion-label id="addon-mod_survey-{{question.id}}">
@ -110,6 +112,7 @@
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-radio-group> </ion-radio-group>
</ng-container>
<!-- Single question (don't belong to a category) --> <!-- Single question (don't belong to a category) -->
<ng-container *ngIf="(!question.multiArray || question.multiArray.length == 0) && question.parent === 0"> <ng-container *ngIf="(!question.multiArray || question.multiArray.length == 0) && question.parent === 0">

View File

@ -67,7 +67,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchSurvey.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchSurvey.bind(this, module, courseId));
} }

View File

@ -130,7 +130,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
/** /**
* @inheritdoc * @inheritdoc
*/ */
async prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> { async prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
// Get the download time of the package before starting the download (otherwise we'd always get current time). // Get the download time of the package before starting the download (otherwise we'd always get current time).
const siteId = CoreSites.getCurrentSiteId(); const siteId = CoreSites.getCurrentSiteId();
@ -138,7 +138,12 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
const downloadTime = data?.downloadTime || 0; const downloadTime = data?.downloadTime || 0;
return this.prefetchPackage(module, courseId, this.prefetchWiki.bind(this, module, courseId, single, downloadTime, siteId)); return this.prefetchPackage(
module,
courseId,
this.prefetchWiki.bind(this, module, courseId, !!single, downloadTime),
siteId,
);
} }
/** /**

View File

@ -210,7 +210,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchWorkshop.bind(this, module, courseId)); return this.prefetchPackage(module, courseId, this.prefetchWorkshop.bind(this, module, courseId));
} }
@ -258,9 +258,6 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
protected async prefetchWorkshop(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> { protected async prefetchWorkshop(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const userIds: number[] = []; const userIds: number[] = [];
const commonOptions = { const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -16,13 +16,14 @@ import { Injector, NgModule } from '@angular/core';
import { RouterModule, ROUTES, Routes } from '@angular/router'; import { RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonNotificationsMainMenuHandlerService } from './services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes { function buildRoutes(injector: Injector): Routes {
return [ return [
{ {
path: 'list', path: 'list',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonNotificationsMainMenuHandlerService.PAGE_NAME,
}, },
loadChildren: () => import('./pages/list/list.module').then(m => m.AddonNotificationsListPageModule), loadChildren: () => import('./pages/list/list.module').then(m => m.AddonNotificationsListPageModule),
}, },

View File

@ -16,13 +16,14 @@ import { Injector, NgModule } from '@angular/core';
import { RouterModule, ROUTES, Routes } from '@angular/router'; import { RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonPrivateFilesMainMenuHandlerService } from './services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes { function buildRoutes(injector: Injector): Routes {
return [ return [
{ {
path: 'root', path: 'root',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: AddonPrivateFilesMainMenuHandlerService.PAGE_NAME,
}, },
loadChildren: () => import('./pages/index/index.module').then(m => m.AddonPrivateFilesIndexPageModule), loadChildren: () => import('./pages/index/index.module').then(m => m.AddonPrivateFilesIndexPageModule),
}, },

View File

@ -78,8 +78,8 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
*/ */
async prefetchPackage( async prefetchPackage(
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number | undefined, courseId: number,
downloadFunction: () => Promise<string>, downloadFunction: (siteId: string) => Promise<string>,
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId(); siteId = siteId || CoreSites.getCurrentSiteId();
@ -111,8 +111,8 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
protected async changeStatusAndPrefetch( protected async changeStatusAndPrefetch(
module: CoreCourseAnyModuleData, module: CoreCourseAnyModuleData,
courseId: number | undefined, courseId: number | undefined,
downloadFunction: () => Promise<string>, downloadFunction: (siteId: string) => Promise<string>,
siteId?: string, siteId: string,
): Promise<void> { ): Promise<void> {
try { try {
await this.setDownloading(module.id, siteId); await this.setDownloading(module.id, siteId);
@ -125,7 +125,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
]); ]);
// Call the download function. // Call the download function.
let extra = await downloadFunction(); let extra = await downloadFunction(siteId);
// Only accept string types. // Only accept string types.
if (typeof extra != 'string') { if (typeof extra != 'string') {

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { CoreError } from '@classes/errors/error';
import { CoreNetworkError } from '@classes/errors/network-error'; import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { CoreApp } from '@services/app'; import { CoreApp } from '@services/app';
@ -191,12 +190,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
* @param dirPath Path of the directory where to store all the content files. * @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
prefetch(module: CoreCourseWSModule, courseId?: number, single?: boolean, dirPath?: string): Promise<void> { prefetch(module: CoreCourseWSModule, courseId: number, single?: boolean, dirPath?: string): Promise<void> {
courseId = courseId || module.course;
if (!courseId) {
throw new CoreError('Course ID not supplied.');
}
return this.downloadOrPrefetch(module, courseId, true, dirPath); return this.downloadOrPrefetch(module, courseId, true, dirPath);
} }

View File

@ -182,7 +182,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
if (!CoreFilepool.getPackageDownloadPromise(siteId, handler.component, module.id)) { if (!CoreFilepool.getPackageDownloadPromise(siteId, handler.component, module.id)) {
// Not handled, the app was probably restarted or something weird happened. // Not handled, the app was probably restarted or something weird happened.
// Re-start download (files already on queue or already downloaded will be skipped). // Re-start download (files already on queue or already downloaded will be skipped).
handler.prefetch(module); handler.prefetch(module, module.course!);
} }
} else if (handler.determineStatus) { } else if (handler.determineStatus) {
// The handler implements a determineStatus function. Apply it. // The handler implements a determineStatus function. Apply it.
@ -1403,7 +1403,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
* @param dirPath Path of the directory where to store all the content files. * @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise<void>; prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean, dirPath?: string): Promise<void>;
/** /**
* Download the module. * Download the module.

View File

@ -23,10 +23,14 @@ import { CoreGradesCoursePage } from './pages/course/course.page';
import { CoreGradesCoursePageModule } from './pages/course/course.module'; import { CoreGradesCoursePageModule } from './pages/course/course.module';
import { CoreGradesCoursesPage } from './pages/courses/courses.page'; import { CoreGradesCoursesPage } from './pages/courses/courses.page';
import { CoreGradesGradePage } from './pages/grade/grade.page'; import { CoreGradesGradePage } from './pages/grade/grade.page';
import { CoreGradesMainMenuHandlerService } from './services/handlers/mainmenu';
const mobileRoutes: Routes = [ const mobileRoutes: Routes = [
{ {
path: '', path: '',
data: {
mainMenuTabRoot: CoreGradesMainMenuHandlerService.PAGE_NAME,
},
component: CoreGradesCoursesPage, component: CoreGradesCoursesPage,
}, },
{ {
@ -42,6 +46,9 @@ const mobileRoutes: Routes = [
const tabletRoutes: Routes = [ const tabletRoutes: Routes = [
{ {
path: '', path: '',
data: {
mainMenuTabRoot: CoreGradesMainMenuHandlerService.PAGE_NAME,
},
component: CoreGradesCoursesPage, component: CoreGradesCoursesPage,
children: [ children: [
{ {

View File

@ -21,6 +21,7 @@ import { CoreSharedModule } from '@/core/shared.module';
import { CoreMainMenuHomePage } from './home'; import { CoreMainMenuHomePage } from './home';
import { MAIN_MENU_HOME_ROUTES } from './home-routing.module'; import { MAIN_MENU_HOME_ROUTES } from './home-routing.module';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreMainMenuHomeHandlerService } from '@features/mainmenu/services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes { function buildRoutes(injector: Injector): Routes {
const routes = resolveModuleRoutes(injector, MAIN_MENU_HOME_ROUTES); const routes = resolveModuleRoutes(injector, MAIN_MENU_HOME_ROUTES);
@ -29,7 +30,7 @@ function buildRoutes(injector: Injector): Routes {
...buildTabMainRoutes(injector, { ...buildTabMainRoutes(injector, {
path: '', path: '',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: CoreMainMenuHomeHandlerService.PAGE_NAME,
}, },
component: CoreMainMenuHomePage, component: CoreMainMenuHomePage,
children: routes.children, children: routes.children,

View File

@ -176,12 +176,12 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
// Current tab was clicked. Check if user is already at root level. // Current tab was clicked. Check if user is already at root level.
const mainMenuRootRoute = CoreNavigator.getCurrentRoute({ routeData: { isMainMenuRoot: true } }); const isMainMenuRoot = await this.currentRouteIsMainMenuRoot();
if (mainMenuRootRoute) { if (isMainMenuRoot) {
return; // Already at root level, nothing to do. return; // Already at root level, nothing to do.
} }
// Current route doesn't define isMainMenuRoot. Check if the current path is the tab one. // Maybe the route isn't defined as it should. Check if the current path is the tab one.
const currentPath = CoreNavigator.getCurrentPath(); const currentPath = CoreNavigator.getCurrentPath();
if (currentPath == `/main/${page}`) { if (currentPath == `/main/${page}`) {
return; // Already at root level, nothing to do. return; // Already at root level, nothing to do.
@ -227,8 +227,8 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
event.detail.register(-10, async (processNextHandler: () => void) => { event.detail.register(-10, async (processNextHandler: () => void) => {
// This callback can be called at the same time as Ionic's back navigation callback. // This callback can be called at the same time as Ionic's back navigation callback.
// Check if user is already at the root of a tab. // Check if user is already at the root of a tab.
const mainMenuRootRoute = CoreNavigator.getCurrentRoute({ routeData: { isMainMenuRoot: true } }); const isMainMenuRoot = await this.currentRouteIsMainMenuRoot();
if (!mainMenuRootRoute) { if (!isMainMenuRoot) {
return; // Not at root level, let Ionic handle the navigation. return; // Not at root level, let Ionic handle the navigation.
} }
@ -257,6 +257,16 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
}); });
} }
/**
* Check if current route is the root of the current main menu tab.
*
* @return Promise.
*/
protected async currentRouteIsMainMenuRoot(): Promise<boolean> {
// Check if the current route is the root of the current main menu tab.
return !!CoreNavigator.getCurrentRoute({ routeData: { mainMenuTabRoot: CoreNavigator.getCurrentMainMenuTab() } });
}
} }
/** /**

View File

@ -18,6 +18,7 @@ import { RouterModule, ROUTES } from '@angular/router';
import { CoreSharedModule } from '@/core/shared.module'; import { CoreSharedModule } from '@/core/shared.module';
import { CoreMainMenuMorePage } from './more'; import { CoreMainMenuMorePage } from './more';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreMainMenuProvider } from '@features/mainmenu/services/mainmenu';
@NgModule({ @NgModule({
imports: [ imports: [
@ -31,7 +32,7 @@ import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.modu
useFactory: (injector: Injector) => buildTabMainRoutes(injector, { useFactory: (injector: Injector) => buildTabMainRoutes(injector, {
component: CoreMainMenuMorePage, component: CoreMainMenuMorePage,
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: CoreMainMenuProvider.MORE_PAGE_NAME,
}, },
}), }),
}, },

View File

@ -222,14 +222,11 @@ export class CoreSitePluginsModulePrefetchHandler extends CoreCourseActivityPref
/** /**
* @inheritdoc * @inheritdoc
*/ */
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise<void> { prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean, dirPath?: string): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
return this.prefetchPackage( return this.prefetchPackage(
module, module,
courseId, courseId,
this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath, siteId), this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath),
siteId,
); );
} }

View File

@ -16,6 +16,7 @@ import { Injector, NgModule } from '@angular/core';
import { Route, RouterModule, ROUTES, Routes } from '@angular/router'; import { Route, RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreTagMainMenuHandlerService } from './services/handlers/mainmenu';
export const CoreTagIndexAreaRoute: Route = { export const CoreTagIndexAreaRoute: Route = {
path: 'index-area', path: 'index-area',
@ -32,7 +33,7 @@ function buildRoutes(injector: Injector): Routes {
{ {
path: 'search', path: 'search',
data: { data: {
isMainMenuRoot: true, mainMenuTabRoot: CoreTagMainMenuHandlerService.PAGE_NAME,
}, },
loadChildren: () => import('@features/tag//pages/search/search.page.module').then(m => m.CoreTagSearchPageModule), loadChildren: () => import('@features/tag//pages/search/search.page.module').then(m => m.CoreTagSearchPageModule),
}, },

View File

@ -629,6 +629,10 @@ export class CoreAppProvider {
* @param color RGB color to use as status bar background. If not set the css variable will be read. * @param color RGB color to use as status bar background. If not set the css variable will be read.
*/ */
setStatusBarColor(color?: string): void { setStatusBarColor(color?: string): void {
if (!this.isMobile()) {
return;
}
if (!color) { if (!color) {
// Get the default color to change it. // Get the default color to change it.
const element = document.querySelector('ion-header ion-toolbar'); const element = document.querySelector('ion-header ion-toolbar');