diff --git a/src/addons/mod/label/constants.ts b/src/addons/mod/label/constants.ts new file mode 100644 index 000000000..c5a39b836 --- /dev/null +++ b/src/addons/mod/label/constants.ts @@ -0,0 +1,15 @@ +// (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_LABEL_COMPONENT = 'mmaModLabel'; diff --git a/src/addons/mod/label/services/handlers/prefetch.ts b/src/addons/mod/label/services/handlers/prefetch.ts index 72f153fa5..bd65a972c 100644 --- a/src/addons/mod/label/services/handlers/prefetch.ts +++ b/src/addons/mod/label/services/handlers/prefetch.ts @@ -19,7 +19,8 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSFile } from '@services/ws'; import { makeSingleton } from '@singletons'; -import { AddonModLabel, AddonModLabelProvider } from '../label'; +import { AddonModLabel } from '../label'; +import { ADDON_MOD_LABEL_COMPONENT } from '../../constants'; /** * Handler to prefetch labels. @@ -29,7 +30,7 @@ export class AddonModLabelPrefetchHandlerService extends CoreCourseResourcePrefe name = 'AddonModLabel'; modName = 'label'; - component = AddonModLabelProvider.COMPONENT; + component = ADDON_MOD_LABEL_COMPONENT; updatesNames = /^.*files$/; /** diff --git a/src/addons/mod/label/services/label.ts b/src/addons/mod/label/services/label.ts index 07f3c0767..f4a5e8260 100644 --- a/src/addons/mod/label/services/label.ts +++ b/src/addons/mod/label/services/label.ts @@ -21,8 +21,7 @@ import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { makeSingleton, Translate } from '@singletons'; - -const ROOT_CACHE_KEY = 'mmaModLabel:'; +import { ADDON_MOD_LABEL_COMPONENT } from '../constants'; /** * Service that provides some features for labels. @@ -30,7 +29,7 @@ const ROOT_CACHE_KEY = 'mmaModLabel:'; @Injectable({ providedIn: 'root' }) export class AddonModLabelProvider { - static readonly COMPONENT = 'mmaModLabel'; + protected static readonly ROOT_CACHE_KEY = 'mmaModLabel:'; /** * Get cache key for label data WS calls. @@ -39,7 +38,7 @@ export class AddonModLabelProvider { * @returns Cache key. */ protected getLabelDataCacheKey(courseId: number): string { - return ROOT_CACHE_KEY + 'label:' + courseId; + return AddonModLabelProvider.ROOT_CACHE_KEY + 'label:' + courseId; } /** @@ -66,7 +65,7 @@ export class AddonModLabelProvider { const preSets: CoreSiteWSPreSets = { cacheKey: this.getLabelDataCacheKey(courseId), updateFrequency: CoreSite.FREQUENCY_RARELY, - component: AddonModLabelProvider.COMPONENT, + component: ADDON_MOD_LABEL_COMPONENT, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), }; @@ -132,7 +131,7 @@ export class AddonModLabelProvider { const promises: Promise[] = []; promises.push(this.invalidateLabelData(courseId, siteId)); - promises.push(CoreFilepool.invalidateFilesByComponent(siteId, AddonModLabelProvider.COMPONENT, moduleId, true)); + promises.push(CoreFilepool.invalidateFilesByComponent(siteId, ADDON_MOD_LABEL_COMPONENT, moduleId, true)); await CoreUtils.allPromises(promises); }