MOBILE-4616 wiki: Move wiki constants to a file

main
Pau Ferrer Ocaña 2024-07-11 22:43:17 +02:00
parent df814d022c
commit ba80f1ce05
12 changed files with 89 additions and 61 deletions

View File

@ -33,11 +33,9 @@ import { CorePath } from '@singletons/path';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { Md5 } from 'ts-md5'; import { Md5 } from 'ts-md5';
import { AddonModWikiPageDBRecord } from '../../services/database/wiki'; import { AddonModWikiPageDBRecord } from '../../services/database/wiki';
import { AddonModWikiModuleHandlerService } from '../../services/handlers/module';
import { import {
AddonModWiki, AddonModWiki,
AddonModWikiPageContents, AddonModWikiPageContents,
AddonModWikiProvider,
AddonModWikiSubwiki, AddonModWikiSubwiki,
AddonModWikiSubwikiListData, AddonModWikiSubwikiListData,
AddonModWikiSubwikiListGrouping, AddonModWikiSubwikiListGrouping,
@ -49,12 +47,18 @@ import { AddonModWikiOffline } from '../../services/wiki-offline';
import { import {
AddonModWikiAutoSyncData, AddonModWikiAutoSyncData,
AddonModWikiSync, AddonModWikiSync,
AddonModWikiSyncProvider,
AddonModWikiSyncWikiResult, AddonModWikiSyncWikiResult,
AddonModWikiSyncWikiSubwiki, AddonModWikiSyncWikiSubwiki,
} from '../../services/wiki-sync'; } from '../../services/wiki-sync';
import { AddonModWikiMapModalComponent, AddonModWikiMapModalReturn } from '../map/map'; import { AddonModWikiMapModalComponent, AddonModWikiMapModalReturn } from '../map/map';
import { AddonModWikiSubwikiPickerComponent } from '../subwiki-picker/subwiki-picker'; import { AddonModWikiSubwikiPickerComponent } from '../subwiki-picker/subwiki-picker';
import {
ADDON_MOD_WIKI_AUTO_SYNCED,
ADDON_MOD_WIKI_COMPONENT,
ADDON_MOD_WIKI_MANUAL_SYNCED,
ADDON_MOD_WIKI_PAGE_CREATED_EVENT,
ADDON_MOD_WIKI_PAGE_NAME,
} from '../../constants';
/** /**
* Component that displays a wiki entry page. * Component that displays a wiki entry page.
@ -73,7 +77,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
@Input() userId?: number; @Input() userId?: number;
@Input() groupId?: number; @Input() groupId?: number;
component = AddonModWikiProvider.COMPONENT; component = ADDON_MOD_WIKI_COMPONENT;
componentId?: number; componentId?: number;
pluginName = 'wiki'; pluginName = 'wiki';
groupWiki = false; groupWiki = false;
@ -99,7 +103,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
count: 0, count: 0,
}; };
protected syncEventName = AddonModWikiSyncProvider.AUTO_SYNCED; protected syncEventName = ADDON_MOD_WIKI_AUTO_SYNCED;
protected currentSubwiki?: AddonModWikiSubwiki; // Current selected subwiki. protected currentSubwiki?: AddonModWikiSubwiki; // Current selected subwiki.
protected currentPage?: number; // Current loaded page ID. protected currentPage?: number; // Current loaded page ID.
protected subwikiPages?: (AddonModWikiSubwikiPage | AddonModWikiPageDBRecord)[]; // List of subwiki pages. protected subwikiPages?: (AddonModWikiSubwikiPage | AddonModWikiPageDBRecord)[]; // List of subwiki pages.
@ -155,7 +159,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
*/ */
protected listenEvents(): void { protected listenEvents(): void {
// Listen for manual sync events. // Listen for manual sync events.
this.manualSyncObserver = CoreEvents.on(AddonModWikiSyncProvider.MANUAL_SYNCED, (data) => { this.manualSyncObserver = CoreEvents.on(ADDON_MOD_WIKI_MANUAL_SYNCED, (data) => {
if (!data || !this.wiki || data.wikiId != this.wiki.id) { if (!data || !this.wiki || data.wikiId != this.wiki.id) {
return; return;
} }
@ -313,7 +317,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
this.pageIsOffline = true; this.pageIsOffline = true;
if (!this.newPageObserver) { if (!this.newPageObserver) {
// It's an offline page, listen for new pages event to detect if the user goes to Edit and submits the page. // It's an offline page, listen for new pages event to detect if the user goes to Edit and submits the page.
this.newPageObserver = CoreEvents.on(AddonModWikiProvider.PAGE_CREATED_EVENT, async (data) => { this.newPageObserver = CoreEvents.on(ADDON_MOD_WIKI_PAGE_CREATED_EVENT, async (data) => {
if (data.subwikiId != this.currentSubwiki?.id || data.pageTitle != title) { if (data.subwikiId != this.currentSubwiki?.id || data.pageTitle != title) {
return; return;
} }
@ -528,7 +532,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
*/ */
protected goToCreateFirstPage(): void { protected goToCreateFirstPage(): void {
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${AddonModWikiModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`, `${ADDON_MOD_WIKI_PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
{ {
params: { params: {
pageTitle: this.wiki?.firstpagetitle ?? '', pageTitle: this.wiki?.firstpagetitle ?? '',
@ -566,7 +570,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
} }
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${AddonModWikiModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`, `${ADDON_MOD_WIKI_PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
{ params: pageParams }, { params: pageParams },
); );
} else if (this.currentSubwiki) { } else if (this.currentSubwiki) {
@ -596,7 +600,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
} }
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${AddonModWikiModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`, `${ADDON_MOD_WIKI_PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
{ params: pageParams }, { params: pageParams },
); );
} else if (this.currentSubwiki) { } else if (this.currentSubwiki) {
@ -644,7 +648,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
})); }));
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${AddonModWikiModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/page/${hash}`, `${ADDON_MOD_WIKI_PAGE_NAME}/${this.courseId}/${this.module.id}/page/${hash}`,
{ {
params: { params: {
module: this.module, module: this.module,
@ -771,7 +775,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
if (result.updated && this.wiki) { if (result.updated && this.wiki) {
// Trigger event. // Trigger event.
this.ignoreManualSyncEvent = true; this.ignoreManualSyncEvent = true;
CoreEvents.trigger(AddonModWikiSyncProvider.MANUAL_SYNCED, { CoreEvents.trigger(ADDON_MOD_WIKI_MANUAL_SYNCED, {
...result, ...result,
wikiId: this.wiki.id, wikiId: this.wiki.id,
}); });

View File

@ -0,0 +1,23 @@
// (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_WIKI_COMPONENT = 'mmaModWiki';
export const ADDON_MOD_WIKI_PAGE_NAME = 'mod_wiki';
export const ADDON_MOD_WIKI_AUTO_SYNCED = 'addon_mod_wiki_autom_synced';
export const ADDON_MOD_WIKI_MANUAL_SYNCED = 'addon_mod_wiki_manual_synced';
export const ADDON_MOD_WIKI_PAGE_CREATED_EVENT = 'addon_mod_wiki_page_created';
export const ADDON_MOD_WIKI_RENEW_LOCK_TIME = 30000; // Milliseconds.

View File

@ -27,10 +27,11 @@ import { CoreWSFile } from '@services/ws';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
import { CoreForms } from '@singletons/form'; import { CoreForms } from '@singletons/form';
import { AddonModWiki, AddonModWikiProvider } from '../../services/wiki'; import { AddonModWiki } from '../../services/wiki';
import { AddonModWikiOffline } from '../../services/wiki-offline'; import { AddonModWikiOffline } from '../../services/wiki-offline';
import { AddonModWikiSync } from '../../services/wiki-sync'; import { AddonModWikiSync } from '../../services/wiki-sync';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_PAGE_CREATED_EVENT, ADDON_MOD_WIKI_RENEW_LOCK_TIME } from '../../constants';
/** /**
* Page that allows adding or editing a wiki page. * Page that allows adding or editing a wiki page.
@ -50,7 +51,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
contentControl: FormControl<string>; // The FormControl for the page content. contentControl: FormControl<string>; // The FormControl for the page content.
canEditTitle = false; // Whether title can be edited. canEditTitle = false; // Whether title can be edited.
loaded = false; // Whether the data has been loaded. loaded = false; // Whether the data has been loaded.
component = AddonModWikiProvider.COMPONENT; // Component to link the files to. component = ADDON_MOD_WIKI_COMPONENT; // Component to link the files to.
wrongVersionLock = false; // Whether the page lock doesn't match the initial one. wrongVersionLock = false; // Whether the page lock doesn't match the initial one.
editorExtraParams: Record<string, unknown> = {}; editorExtraParams: Record<string, unknown> = {};
@ -190,7 +191,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
// Renew the lock every certain time. // Renew the lock every certain time.
this.renewLockInterval = window.setInterval(() => { this.renewLockInterval = window.setInterval(() => {
this.renewLock(); this.renewLock();
}, AddonModWikiProvider.RENEW_LOCK_TIME); }, ADDON_MOD_WIKI_RENEW_LOCK_TIME);
} }
} else { } else {
const pageTitle = this.pageForm.controls.title.value; const pageTitle = this.pageForm.controls.title.value;
@ -442,7 +443,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
await CoreUtils.ignoreErrors(Promise.all(promises)); await CoreUtils.ignoreErrors(Promise.all(promises));
// Notify page created. // Notify page created.
CoreEvents.trigger(AddonModWikiProvider.PAGE_CREATED_EVENT, { CoreEvents.trigger(ADDON_MOD_WIKI_PAGE_CREATED_EVENT, {
pageId: this.pageId, pageId: this.pageId,
subwikiId: this.subwikiId, subwikiId: this.subwikiId,
pageTitle: title, pageTitle: title,

View File

@ -23,7 +23,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModWikiIndexPage } from '../../pages/index'; import { AddonModWikiIndexPage } from '../../pages/index';
import { AddonModWiki } from '../wiki'; import { AddonModWiki } from '../wiki';
import { AddonModWikiModuleHandlerService } from './module'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants';
/** /**
* Handler to treat links to create a wiki page. * Handler to treat links to create a wiki page.
@ -109,7 +109,7 @@ export class AddonModWikiCreateLinkHandlerService extends CoreContentLinksHandle
} }
const subwikiId = parseInt(params.swid, 10); const subwikiId = parseInt(params.swid, 10);
const wikiId = parseInt(params.wid, 10); const wikiId = parseInt(params.wid, 10);
let path = AddonModWikiModuleHandlerService.PAGE_NAME; let path = ADDON_MOD_WIKI_PAGE_NAME;
// Check if the link is inside the same wiki. // Check if the link is inside the same wiki.
const isSameWiki = await this.currentStateIsSameWiki(route, subwikiId, siteId); const isSameWiki = await this.currentStateIsSameWiki(route, subwikiId, siteId);

View File

@ -21,7 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModWiki } from '../wiki'; import { AddonModWiki } from '../wiki';
import { AddonModWikiModuleHandlerService } from './module'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants';
/** /**
* Handler to treat links to edit a wiki page. * Handler to treat links to edit a wiki page.
@ -63,7 +63,7 @@ export class AddonModWikiEditLinkHandlerService extends CoreContentLinksHandlerB
} }
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
AddonModWikiModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/edit`, `${ADDON_MOD_WIKI_PAGE_NAME}/${module.course}/${module.id}/edit`,
{ {
params: { params: {
section: section, section: section,

View File

@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate'; import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants';
/** /**
* Handler to support wiki modules. * Handler to support wiki modules.
@ -24,11 +25,9 @@ import { makeSingleton } from '@singletons';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModWikiModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { export class AddonModWikiModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_wiki';
name = 'AddonModWiki'; name = 'AddonModWiki';
modName = 'wiki'; modName = 'wiki';
protected pageName = AddonModWikiModuleHandlerService.PAGE_NAME; protected pageName = ADDON_MOD_WIKI_PAGE_NAME;
supportedFeatures = { supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: true, [CoreConstants.FEATURE_GROUPS]: true,

View File

@ -22,7 +22,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { Md5 } from 'ts-md5'; import { Md5 } from 'ts-md5';
import { AddonModWiki } from '../wiki'; import { AddonModWiki } from '../wiki';
import { AddonModWikiModuleHandlerService } from './module'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants';
/** /**
* Handler to treat links to a wiki page or the wiki map. * Handler to treat links to a wiki page or the wiki map.
@ -68,7 +68,7 @@ export class AddonModWikiPageOrMapLinkHandlerService extends CoreContentLinksHan
})); }));
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
AddonModWikiModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/page/${hash}`, `${ADDON_MOD_WIKI_PAGE_NAME}/${module.course}/${module.id}/page/${hash}`,
{ {
params: { params: {
module, module,

View File

@ -22,8 +22,9 @@ import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@
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';
import { AddonModWiki, AddonModWikiProvider, AddonModWikiSubwikiPage } from '../wiki'; import { AddonModWiki, AddonModWikiSubwikiPage } from '../wiki';
import { AddonModWikiSync, AddonModWikiSyncWikiResult } from '../wiki-sync'; import { AddonModWikiSync, AddonModWikiSyncWikiResult } from '../wiki-sync';
import { ADDON_MOD_WIKI_COMPONENT } from '../../constants';
/** /**
* Handler to prefetch wikis. * Handler to prefetch wikis.
@ -33,7 +34,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
name = 'AddonModWiki'; name = 'AddonModWiki';
modName = 'wiki'; modName = 'wiki';
component = AddonModWikiProvider.COMPONENT; component = ADDON_MOD_WIKI_COMPONENT;
updatesNames = /^.*files$|^pages$/; updatesNames = /^.*files$|^pages$/;
/** /**

View File

@ -24,8 +24,9 @@ import { CoreUtils } from '@services/utils/utils';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
import { AddonModWikiPageDBRecord } from './database/wiki'; import { AddonModWikiPageDBRecord } from './database/wiki';
import { AddonModWiki, AddonModWikiProvider } from './wiki'; import { AddonModWiki } from './wiki';
import { AddonModWikiOffline } from './wiki-offline'; import { AddonModWikiOffline } from './wiki-offline';
import { ADDON_MOD_WIKI_AUTO_SYNCED, ADDON_MOD_WIKI_COMPONENT } from '../constants';
/** /**
* Service to sync wikis. * Service to sync wikis.
@ -33,9 +34,6 @@ import { AddonModWikiOffline } from './wiki-offline';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiSyncSubwikiResult> { export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiSyncSubwikiResult> {
static readonly AUTO_SYNCED = 'addon_mod_wiki_autom_synced';
static readonly MANUAL_SYNCED = 'addon_mod_wiki_manual_synced';
protected componentTranslatableString = 'wiki'; protected componentTranslatableString = 'wiki';
constructor() { constructor() {
@ -106,7 +104,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiS
if (result?.updated) { if (result?.updated) {
// Sync successful, send event. // Sync successful, send event.
CoreEvents.trigger(AddonModWikiSyncProvider.AUTO_SYNCED, { CoreEvents.trigger(ADDON_MOD_WIKI_AUTO_SYNCED, {
siteId: siteId, siteId: siteId,
subwikiId: page.subwikiid, subwikiId: page.subwikiid,
wikiId: page.wikiid, wikiId: page.wikiid,
@ -175,7 +173,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiS
} }
// Verify that subwiki isn't blocked. // Verify that subwiki isn't blocked.
if (CoreSync.isBlocked(AddonModWikiProvider.COMPONENT, subwikiBlockId, siteId)) { if (CoreSync.isBlocked(ADDON_MOD_WIKI_COMPONENT, subwikiBlockId, siteId)) {
this.logger.debug(`Cannot sync subwiki ${subwikiBlockId} because it is blocked.`); this.logger.debug(`Cannot sync subwiki ${subwikiBlockId} because it is blocked.`);
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
@ -290,7 +288,7 @@ export class AddonModWikiSyncProvider extends CoreSyncBaseProvider<AddonModWikiS
siteId = siteId || CoreSites.getCurrentSiteId(); siteId = siteId || CoreSites.getCurrentSiteId();
// Sync offline logs. // Sync offline logs.
await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(AddonModWikiProvider.COMPONENT, wikiId, siteId)); await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(ADDON_MOD_WIKI_COMPONENT, wikiId, siteId));
// Sync is done at subwiki level, get all the subwikis. // Sync is done at subwiki level, get all the subwikis.
const subwikis = await AddonModWiki.getSubwikis(wikiId, { cmId, siteId }); const subwikis = await AddonModWiki.getSubwikis(wikiId, { cmId, siteId });

View File

@ -27,10 +27,14 @@ import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
import { AddonModWikiPageDBRecord } from './database/wiki'; import { AddonModWikiPageDBRecord } from './database/wiki';
import { AddonModWikiOffline } from './wiki-offline'; import { AddonModWikiOffline } from './wiki-offline';
import { AddonModWikiAutoSyncData, AddonModWikiManualSyncData, AddonModWikiSyncProvider } from './wiki-sync'; import { AddonModWikiAutoSyncData, AddonModWikiManualSyncData } from './wiki-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import {
const ROOT_CACHE_KEY = 'mmaModWiki:'; ADDON_MOD_WIKI_AUTO_SYNCED,
ADDON_MOD_WIKI_COMPONENT,
ADDON_MOD_WIKI_MANUAL_SYNCED,
ADDON_MOD_WIKI_PAGE_CREATED_EVENT,
} from '../constants';
/** /**
* Service that provides some features for wikis. * Service that provides some features for wikis.
@ -38,9 +42,7 @@ const ROOT_CACHE_KEY = 'mmaModWiki:';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModWikiProvider { export class AddonModWikiProvider {
static readonly COMPONENT = 'mmaModWiki'; protected static readonly ROOT_CACHE_KEY = 'mmaModWiki:';
static readonly PAGE_CREATED_EVENT = 'addon_mod_wiki_page_created';
static readonly RENEW_LOCK_TIME = 30000; // Milliseconds.
protected subwikiListsCache: {[wikiId: number]: AddonModWikiSubwikiListData} = {}; protected subwikiListsCache: {[wikiId: number]: AddonModWikiSubwikiListData} = {};
protected wikiFirstViewedPage: Record<string, Record<number, string>> = {}; protected wikiFirstViewedPage: Record<string, Record<number, string>> = {};
@ -137,7 +139,7 @@ export class AddonModWikiProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getPageContentsCacheKey(pageId), cacheKey: this.getPageContentsCacheKey(pageId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES, updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModWikiProvider.COMPONENT, component: ADDON_MOD_WIKI_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -154,7 +156,7 @@ export class AddonModWikiProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getPageContentsCacheKey(pageId: number): string { protected getPageContentsCacheKey(pageId: number): string {
return ROOT_CACHE_KEY + 'page:' + pageId; return AddonModWikiProvider.ROOT_CACHE_KEY + 'page:' + pageId;
} }
/** /**
@ -210,7 +212,7 @@ export class AddonModWikiProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getSubwikiFilesCacheKey(wikiId, groupId, userId), cacheKey: this.getSubwikiFilesCacheKey(wikiId, groupId, userId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES, updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModWikiProvider.COMPONENT, component: ADDON_MOD_WIKI_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -239,7 +241,7 @@ export class AddonModWikiProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getSubwikiFilesCacheKeyPrefix(wikiId: number): string { protected getSubwikiFilesCacheKeyPrefix(wikiId: number): string {
return ROOT_CACHE_KEY + 'subwikifiles:' + wikiId; return AddonModWikiProvider.ROOT_CACHE_KEY + 'subwikifiles:' + wikiId;
} }
/** /**
@ -280,7 +282,7 @@ export class AddonModWikiProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getSubwikiPagesCacheKey(wikiId, groupId, userId), cacheKey: this.getSubwikiPagesCacheKey(wikiId, groupId, userId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES, updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModWikiProvider.COMPONENT, component: ADDON_MOD_WIKI_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -309,7 +311,7 @@ export class AddonModWikiProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getSubwikiPagesCacheKeyPrefix(wikiId: number): string { protected getSubwikiPagesCacheKeyPrefix(wikiId: number): string {
return ROOT_CACHE_KEY + 'subwikipages:' + wikiId; return AddonModWikiProvider.ROOT_CACHE_KEY + 'subwikipages:' + wikiId;
} }
/** /**
@ -328,7 +330,7 @@ export class AddonModWikiProvider {
const preSets = { const preSets = {
cacheKey: this.getSubwikisCacheKey(wikiId), cacheKey: this.getSubwikisCacheKey(wikiId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModWikiProvider.COMPONENT, component: ADDON_MOD_WIKI_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -348,7 +350,7 @@ export class AddonModWikiProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getSubwikisCacheKey(wikiId: number): string { protected getSubwikisCacheKey(wikiId: number): string {
return ROOT_CACHE_KEY + 'subwikis:' + wikiId; return AddonModWikiProvider.ROOT_CACHE_KEY + 'subwikis:' + wikiId;
} }
/** /**
@ -386,7 +388,7 @@ export class AddonModWikiProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getWikiDataCacheKey(courseId), cacheKey: this.getWikiDataCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModWikiProvider.COMPONENT, component: ADDON_MOD_WIKI_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -419,7 +421,7 @@ export class AddonModWikiProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getWikiDataCacheKey(courseId: number): string { protected getWikiDataCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'wiki:' + courseId; return AddonModWikiProvider.ROOT_CACHE_KEY + 'wiki:' + courseId;
} }
/** /**
@ -633,7 +635,7 @@ export class AddonModWikiProvider {
return CoreCourseLogHelper.log( return CoreCourseLogHelper.log(
'mod_wiki_view_page', 'mod_wiki_view_page',
params, params,
AddonModWikiProvider.COMPONENT, ADDON_MOD_WIKI_COMPONENT,
wikiId, wikiId,
siteId, siteId,
); );
@ -654,7 +656,7 @@ export class AddonModWikiProvider {
return CoreCourseLogHelper.log( return CoreCourseLogHelper.log(
'mod_wiki_view_wiki', 'mod_wiki_view_wiki',
params, params,
AddonModWikiProvider.COMPONENT, ADDON_MOD_WIKI_COMPONENT,
id, id,
siteId, siteId,
); );
@ -895,9 +897,9 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/ */
export interface CoreEventsData { export interface CoreEventsData {
[AddonModWikiProvider.PAGE_CREATED_EVENT]: AddonModWikiPageCreatedData; [ADDON_MOD_WIKI_PAGE_CREATED_EVENT]: AddonModWikiPageCreatedData;
[AddonModWikiSyncProvider.AUTO_SYNCED]: AddonModWikiAutoSyncData; [ADDON_MOD_WIKI_AUTO_SYNCED]: AddonModWikiAutoSyncData;
[AddonModWikiSyncProvider.MANUAL_SYNCED]: AddonModWikiManualSyncData; [ADDON_MOD_WIKI_MANUAL_SYNCED]: AddonModWikiManualSyncData;
} }
} }

View File

@ -49,4 +49,4 @@ const routes: Routes = [
AddonModWikiEditPage, AddonModWikiEditPage,
], ],
}) })
export class AddonModWikiLazyModule {} export default class AddonModWikiLazyModule {}

View File

@ -27,17 +27,17 @@ import { AddonModWikiCreateLinkHandler } from './services/handlers/create-link';
import { AddonModWikiEditLinkHandler } from './services/handlers/edit-link'; import { AddonModWikiEditLinkHandler } from './services/handlers/edit-link';
import { AddonModWikiIndexLinkHandler } from './services/handlers/index-link'; import { AddonModWikiIndexLinkHandler } from './services/handlers/index-link';
import { AddonModWikiListLinkHandler } from './services/handlers/list-link'; import { AddonModWikiListLinkHandler } from './services/handlers/list-link';
import { AddonModWikiModuleHandler, AddonModWikiModuleHandlerService } from './services/handlers/module'; import { AddonModWikiModuleHandler } from './services/handlers/module';
import { AddonModWikiPageOrMapLinkHandler } from './services/handlers/page-or-map-link'; import { AddonModWikiPageOrMapLinkHandler } from './services/handlers/page-or-map-link';
import { AddonModWikiPrefetchHandler } from './services/handlers/prefetch'; import { AddonModWikiPrefetchHandler } from './services/handlers/prefetch';
import { AddonModWikiSyncCronHandler } from './services/handlers/sync-cron'; import { AddonModWikiSyncCronHandler } from './services/handlers/sync-cron';
import { AddonModWikiTagAreaHandler } from './services/handlers/tag-area'; import { AddonModWikiTagAreaHandler } from './services/handlers/tag-area';
import { AddonModWikiProvider } from './services/wiki'; import { ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_PAGE_NAME } from './constants';
const routes: Routes = [ const routes: Routes = [
{ {
path: AddonModWikiModuleHandlerService.PAGE_NAME, path: ADDON_MOD_WIKI_PAGE_NAME,
loadChildren: () => import('./wiki-lazy.module').then(m => m.AddonModWikiLazyModule), loadChildren: () => import('./wiki-lazy.module'),
}, },
]; ];
@ -65,7 +65,7 @@ const routes: Routes = [
CoreContentLinksDelegate.registerHandler(AddonModWikiPageOrMapLinkHandler.instance); CoreContentLinksDelegate.registerHandler(AddonModWikiPageOrMapLinkHandler.instance);
CoreTagAreaDelegate.registerHandler(AddonModWikiTagAreaHandler.instance); CoreTagAreaDelegate.registerHandler(AddonModWikiTagAreaHandler.instance);
CoreCourseHelper.registerModuleReminderClick(AddonModWikiProvider.COMPONENT); CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_WIKI_COMPONENT);
}, },
}, },
], ],