Skip to content

Commit e9601ae

Browse files
committed
MOBILE-4362 glossary: Fix some pages not prefetched
1 parent e958210 commit e9601ae

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/addons/mod/glossary/services/glossary.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,16 @@ export class AddonModGlossaryProvider {
291291
glossaryId: number,
292292
options: AddonModGlossaryGetEntriesOptions = {},
293293
): Promise<AddonModGlossaryGetEntriesWSResponse> {
294-
options.from = options.from || 0;
295-
options.limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES;
294+
const from = options.from || 0;
295+
const limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES;
296296

297297
const site = await CoreSites.getSite(options.siteId);
298298

299299
const params: AddonModGlossaryGetEntriesByLetterWSParams = {
300300
id: glossaryId,
301301
letter: 'ALL',
302-
from: options.from,
303-
limit: options.limit,
302+
from,
303+
limit,
304304
};
305305
const preSets: CoreSiteWSPreSets = {
306306
cacheKey: this.getEntriesByLetterCacheKey(glossaryId),
@@ -316,9 +316,9 @@ export class AddonModGlossaryProvider {
316316
preSets,
317317
);
318318

319-
if (options.limit == AddonModGlossaryProvider.LIMIT_ENTRIES) {
319+
if (limit === AddonModGlossaryProvider.LIMIT_ENTRIES) {
320320
// Store entries in background, don't block the user for this.
321-
CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, options.from, site.getId()));
321+
CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, from, site.getId()));
322322
}
323323

324324
return result;
@@ -446,13 +446,13 @@ export class AddonModGlossaryProvider {
446446
site: CoreSite,
447447
options: AddonModGlossaryGetCategoriesOptions = {},
448448
): Promise<AddonModGlossaryCategory[]> {
449-
options.from = options.from || 0;
450-
options.limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES;
449+
const from = options.from || 0;
450+
const limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES;
451451

452452
const params: AddonModGlossaryGetCategoriesWSParams = {
453453
id: glossaryId,
454-
from: options.from,
455-
limit: options.limit,
454+
from,
455+
limit,
456456
};
457457
const preSets: CoreSiteWSPreSets = {
458458
cacheKey: this.getCategoriesCacheKey(glossaryId),
@@ -465,11 +465,12 @@ export class AddonModGlossaryProvider {
465465
const response = await site.read<AddonModGlossaryGetCategoriesWSResponse>('mod_glossary_get_categories', params, preSets);
466466

467467
categories = categories.concat(response.categories);
468-
const canLoadMore = (options.from + options.limit) < response.count;
468+
const canLoadMore = (from + limit) < response.count;
469469
if (canLoadMore) {
470-
options.from += options.limit;
471-
472-
return this.getCategories(glossaryId, categories, site, options);
470+
return this.getCategories(glossaryId, categories, site, {
471+
...options,
472+
from: from + limit,
473+
});
473474
}
474475

475476
return categories;

0 commit comments

Comments
 (0)