diff --git a/src/addons/mod/glossary/services/glossary.ts b/src/addons/mod/glossary/services/glossary.ts index fef56bab530..bb5e1eb0f2d 100644 --- a/src/addons/mod/glossary/services/glossary.ts +++ b/src/addons/mod/glossary/services/glossary.ts @@ -291,16 +291,16 @@ export class AddonModGlossaryProvider { glossaryId: number, options: AddonModGlossaryGetEntriesOptions = {}, ): Promise { - options.from = options.from || 0; - options.limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES; + const from = options.from || 0; + const limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES; const site = await CoreSites.getSite(options.siteId); const params: AddonModGlossaryGetEntriesByLetterWSParams = { id: glossaryId, letter: 'ALL', - from: options.from, - limit: options.limit, + from, + limit, }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getEntriesByLetterCacheKey(glossaryId), @@ -316,9 +316,9 @@ export class AddonModGlossaryProvider { preSets, ); - if (options.limit == AddonModGlossaryProvider.LIMIT_ENTRIES) { + if (limit === AddonModGlossaryProvider.LIMIT_ENTRIES) { // Store entries in background, don't block the user for this. - CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, options.from, site.getId())); + CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, from, site.getId())); } return result; @@ -446,13 +446,13 @@ export class AddonModGlossaryProvider { site: CoreSite, options: AddonModGlossaryGetCategoriesOptions = {}, ): Promise { - options.from = options.from || 0; - options.limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES; + const from = options.from || 0; + const limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES; const params: AddonModGlossaryGetCategoriesWSParams = { id: glossaryId, - from: options.from, - limit: options.limit, + from, + limit, }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getCategoriesCacheKey(glossaryId), @@ -465,11 +465,12 @@ export class AddonModGlossaryProvider { const response = await site.read('mod_glossary_get_categories', params, preSets); categories = categories.concat(response.categories); - const canLoadMore = (options.from + options.limit) < response.count; + const canLoadMore = (from + limit) < response.count; if (canLoadMore) { - options.from += options.limit; - - return this.getCategories(glossaryId, categories, site, options); + return this.getCategories(glossaryId, categories, site, { + ...options, + from: from + limit, + }); } return categories;