From 06fec4e6cfef541adeb0c4f1a647011c5d50371f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 11 Jul 2024 22:39:31 +0200 Subject: [PATCH] MOBILE-4616 bbb: Move bbb constants to a file --- .../bigbluebuttonbn-lazy.module.ts | 2 +- .../bigbluebuttonbn/bigbluebuttonbn.module.ts | 7 ++++--- .../bigbluebuttonbn/components/index/index.ts | 4 ++-- src/addons/mod/bigbluebuttonbn/constants.ts | 16 ++++++++++++++++ .../services/bigbluebuttonbn.ts | 19 +++++++++---------- .../services/handlers/module.ts | 5 ++--- 6 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 src/addons/mod/bigbluebuttonbn/constants.ts diff --git a/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn-lazy.module.ts b/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn-lazy.module.ts index e2152edb4..a5bf8810a 100644 --- a/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn-lazy.module.ts +++ b/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn-lazy.module.ts @@ -35,4 +35,4 @@ const routes: Routes = [ AddonModBBBIndexPage, ], }) -export class AddonModBBBLazyModule {} +export default class AddonModBBBLazyModule {} diff --git a/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn.module.ts b/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn.module.ts index 131966598..b81a3185b 100644 --- a/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn.module.ts +++ b/src/addons/mod/bigbluebuttonbn/bigbluebuttonbn.module.ts @@ -19,12 +19,13 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { AddonModBBBIndexLinkHandler } from './services/handlers/index-link'; import { AddonModBBBListLinkHandler } from './services/handlers/list-link'; -import { AddonModBBBModuleHandler, ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME } from './services/handlers/module'; +import { AddonModBBBModuleHandler } from './services/handlers/module'; +import { ADDON_MOD_BBB_PAGE_NAME } from './constants'; const routes: Routes = [ { - path: ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME, - loadChildren: () => import('./bigbluebuttonbn-lazy.module').then(m => m.AddonModBBBLazyModule), + path: ADDON_MOD_BBB_PAGE_NAME, + loadChildren: () => import('./bigbluebuttonbn-lazy.module'), }, ]; diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.ts b/src/addons/mod/bigbluebuttonbn/components/index/index.ts index 92914b8ae..b4f61d185 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.ts +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.ts @@ -30,8 +30,8 @@ import { AddonModBBBData, AddonModBBBMeetingInfo, AddonModBBBRecordingPlaybackTypes, - AddonModBBBService, } from '../../services/bigbluebuttonbn'; +import { ADDON_MOD_BBB_COMPONENT } from '../../constants'; /** * Component that displays a Big Blue Button activity. @@ -43,7 +43,7 @@ import { }) export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit { - component = AddonModBBBService.COMPONENT; + component = ADDON_MOD_BBB_COMPONENT; pluginName = 'bigbluebuttonbn'; bbb?: AddonModBBBData; groupInfo?: CoreGroupInfo; diff --git a/src/addons/mod/bigbluebuttonbn/constants.ts b/src/addons/mod/bigbluebuttonbn/constants.ts new file mode 100644 index 000000000..db8e8190e --- /dev/null +++ b/src/addons/mod/bigbluebuttonbn/constants.ts @@ -0,0 +1,16 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +export const ADDON_MOD_BBB_COMPONENT = 'mmaModBigBlueButtonBN'; +export const ADDON_MOD_BBB_PAGE_NAME = 'mod_bigbluebuttonbn'; diff --git a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts index eb226fe30..a96f4e5d3 100644 --- a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts +++ b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts @@ -24,8 +24,7 @@ import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { makeSingleton, Translate } from '@singletons'; - -const ROOT_CACHE_KEY = 'AddonModBBB:'; +import { ADDON_MOD_BBB_COMPONENT } from '../constants'; /** * Service that provides some features for Big Blue Button activity. @@ -33,7 +32,7 @@ const ROOT_CACHE_KEY = 'AddonModBBB:'; @Injectable({ providedIn: 'root' }) export class AddonModBBBService { - static readonly COMPONENT = 'mmaModBigBlueButtonBN'; + protected static readonly ROOT_CACHE_KEY = 'AddonModBBB:'; /** * End a meeting. @@ -75,7 +74,7 @@ export class AddonModBBBService { const preSets: CoreSiteWSPreSets = { cacheKey: this.getBBBsCacheKey(courseId), updateFrequency: CoreSite.FREQUENCY_RARELY, - component: AddonModBBBService.COMPONENT, + component: ADDON_MOD_BBB_COMPONENT, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; @@ -100,7 +99,7 @@ export class AddonModBBBService { * @returns Cache key. */ protected getBBBsCacheKey(courseId: number): string { - return ROOT_CACHE_KEY + 'bbb:' + courseId; + return AddonModBBBService.ROOT_CACHE_KEY + 'bbb:' + courseId; } /** @@ -166,7 +165,7 @@ export class AddonModBBBService { cacheKey: this.getMeetingInfoCacheKey(id, groupId), getCacheUsingCacheKey: true, uniqueCacheKey: true, - component: AddonModBBBService.COMPONENT, + component: ADDON_MOD_BBB_COMPONENT, componentId: options.cmId, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; @@ -205,7 +204,7 @@ export class AddonModBBBService { * @returns Cache key prefix. */ protected getMeetingInfoCacheKeyPrefix(id: number): string { - return ROOT_CACHE_KEY + 'meetingInfo:' + id + ':'; + return AddonModBBBService.ROOT_CACHE_KEY + 'meetingInfo:' + id + ':'; } /** @@ -229,7 +228,7 @@ export class AddonModBBBService { }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getRecordingsCacheKey(id, groupId), - component: AddonModBBBService.COMPONENT, + component: ADDON_MOD_BBB_COMPONENT, componentId: options.cmId, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; @@ -270,7 +269,7 @@ export class AddonModBBBService { * @returns Cache key prefix. */ protected getRecordingsCacheKeyPrefix(id: number): string { - return ROOT_CACHE_KEY + 'recordings:' + id + ':'; + return AddonModBBBService.ROOT_CACHE_KEY + 'recordings:' + id + ':'; } /** @@ -288,7 +287,7 @@ export class AddonModBBBService { await CoreCourseLogHelper.log( 'mod_bigbluebuttonbn_view_bigbluebuttonbn', params, - AddonModBBBService.COMPONENT, + ADDON_MOD_BBB_COMPONENT, id, siteId, ); diff --git a/src/addons/mod/bigbluebuttonbn/services/handlers/module.ts b/src/addons/mod/bigbluebuttonbn/services/handlers/module.ts index ee71b6308..b458cc618 100644 --- a/src/addons/mod/bigbluebuttonbn/services/handlers/module.ts +++ b/src/addons/mod/bigbluebuttonbn/services/handlers/module.ts @@ -22,8 +22,7 @@ import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins'; import { makeSingleton } from '@singletons'; import { AddonModBBBIndexComponent } from '../../components/index'; import { AddonModBBB } from '../bigbluebuttonbn'; - -export const ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME = 'mod_bigbluebuttonbn'; +import { ADDON_MOD_BBB_PAGE_NAME } from '../../constants'; /** * Handler to support Big Blue Button activities. @@ -33,7 +32,7 @@ export class AddonModBBBModuleHandlerService extends CoreModuleHandlerBase imple name = 'AddonModBBB'; modName = 'bigbluebuttonbn'; - protected pageName = ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME; + protected pageName = ADDON_MOD_BBB_PAGE_NAME; protected sitePluginHandler?: CoreSitePluginsModuleHandler; supportedFeatures = {