Merge pull request #2621 from crazyserver/MOBILE-3523

MOBILE-3523 data: Fix database prefetch
main
Dani Palou 2020-11-25 14:04:11 +01:00 committed by GitHub
commit 6d8aabc04d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -260,6 +260,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
sort: Number(this.search.sortBy),
order: this.search.sortDirection,
page: this.search.page,
cmId: this.module.id,
}).then((entries) => {
const numEntries = entries.entries.length;
const numOfflineEntries = entries.offlineEntries.length;

View File

@ -608,8 +608,11 @@ export class AddonModDataProvider {
*/
getDatabaseAccessInformation(dataId: number, options: AddonModDataAccessInfoOptions = {}): Promise<any> {
return this.sitesProvider.getSite(options.siteId).then((site) => {
options.groupId = options.groupId || 0;
const params = {
databaseid: dataId,
groupid: options.groupId,
};
const preSets = {
cacheKey: this.getDatabaseAccessInformationDataCacheKey(dataId, options.groupId),
@ -618,10 +621,6 @@ export class AddonModDataProvider {
...this.sitesProvider.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
if (typeof options.groupId !== 'undefined') {
params['groupid'] = options.groupId;
}
return site.read('mod_data_get_data_access_information', params, preSets);
});
}
@ -636,7 +635,7 @@ export class AddonModDataProvider {
getEntries(dataId: number, options: AddonModDataGetEntriesOptions = {}): Promise<AddonModDataEntries> {
options.groupId = options.groupId || 0;
options.sort = options.sort || 0;
options.order || options.order || 'DESC';
options.order = options.order || 'DESC';
options.page = options.page || 0;
options.perPage = options.perPage || AddonModDataProvider.PER_PAGE;

View File

@ -22,7 +22,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
import { CoreGroupsProvider } from '@providers/groups';
import { CoreTimeUtilsProvider } from '@providers/utils/time';
import { CoreCommentsProvider } from '@core/comments/providers/comments';
import { CoreCourseProvider } from '@core/course/providers/course';
import { CoreCourseProvider, CoreCourseCommonModWSOptions } from '@core/course/providers/course';
import { CoreCourseActivityPrefetchHandlerBase } from '@core/course/classes/activity-prefetch-handler';
import { AddonModDataProvider, AddonModDataEntry } from './data';
import { AddonModDataSyncProvider } from './sync';
@ -100,13 +100,14 @@ export class AddonModDataPrefetchHandler extends CoreCourseActivityPrefetchHandl
* @param options Other options.
* @return Promise resolved with the info fetched.
*/
protected getDatabaseInfoHelper(module: any, courseId: number, omitFail: boolean, options: CoreSitesCommonWSOptions = {})
protected getDatabaseInfoHelper(module: any, courseId: number, omitFail: boolean, options: CoreCourseCommonModWSOptions = {})
: Promise<any> {
let database,
groups = [],
entries = [],
files = [];
options.cmId = options.cmId || module.id;
options.siteId = options.siteId || this.sitesProvider.getCurrentSiteId();
return this.dataProvider.getDatabase(courseId, module.id, options).then((data) => {