MOBILE-3245 naming: Prefix ReadingStrategy name with CoreSites
parent
accb83b339
commit
5ba3c03d91
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
import { CoreSitesProvider, ReadingStrategy } from '@providers/sites';
|
import { CoreSitesProvider, CoreSitesReadingStrategy } from '@providers/sites';
|
||||||
import { CoreSite } from '@classes/site';
|
import { CoreSite } from '@classes/site';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -774,7 +774,7 @@ export class CoreCoursesProvider {
|
||||||
* @param siteId Site to get the courses from. If not defined, use current site.
|
* @param siteId Site to get the courses from. If not defined, use current site.
|
||||||
* @return Promise resolved with the courses.
|
* @return Promise resolved with the courses.
|
||||||
*/
|
*/
|
||||||
getUserCourses(preferCache?: boolean, siteId?: string, strategy?: ReadingStrategy): Promise<any[]> {
|
getUserCourses(preferCache?: boolean, siteId?: string, strategy?: CoreSitesReadingStrategy): Promise<any[]> {
|
||||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||||
|
|
||||||
const userId = site.getUserId(),
|
const userId = site.getUserId(),
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { NavController } from 'ionic-angular';
|
import { NavController } from 'ionic-angular';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
import { CoreSitesProvider, ReadingStrategy } from '@providers/sites';
|
import { CoreSitesProvider, CoreSitesReadingStrategy } from '@providers/sites';
|
||||||
import { CoreCoursesProvider } from '@core/courses/providers/courses';
|
import { CoreCoursesProvider } from '@core/courses/providers/courses';
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreGradesProvider } from './grades';
|
import { CoreGradesProvider } from './grades';
|
||||||
|
@ -203,7 +203,7 @@ export class CoreGradesHelperProvider {
|
||||||
let coursesWereMissing;
|
let coursesWereMissing;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const courses = await this.coursesProvider.getUserCourses(undefined, undefined, ReadingStrategy.OnlyCache);
|
const courses = await this.coursesProvider.getUserCourses(undefined, undefined, CoreSitesReadingStrategy.OnlyCache);
|
||||||
|
|
||||||
const coursesMap = this.utils.arrayToObject(courses, 'id');
|
const coursesMap = this.utils.arrayToObject(courses, 'id');
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ export class CoreGradesHelperProvider {
|
||||||
if (coursesWereMissing) {
|
if (coursesWereMissing) {
|
||||||
const coursesPromise = this.coursesProvider.isGetCoursesByFieldAvailable()
|
const coursesPromise = this.coursesProvider.isGetCoursesByFieldAvailable()
|
||||||
? this.coursesProvider.getCoursesByField('ids', grades.map((grade) => grade.courseid).join(','))
|
? this.coursesProvider.getCoursesByField('ids', grades.map((grade) => grade.courseid).join(','))
|
||||||
: this.coursesProvider.getUserCourses(undefined, undefined, ReadingStrategy.PreferNetwork);
|
: this.coursesProvider.getUserCourses(undefined, undefined, CoreSitesReadingStrategy.PreferNetwork);
|
||||||
|
|
||||||
const courses = await coursesPromise;
|
const courses = await coursesPromise;
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ export interface CoreSiteSchema {
|
||||||
migrate?(db: SQLiteDB, oldVersion: number, siteId: string): Promise<any> | void;
|
migrate?(db: SQLiteDB, oldVersion: number, siteId: string): Promise<any> | void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum ReadingStrategy {
|
export const enum CoreSitesReadingStrategy {
|
||||||
OnlyCache,
|
OnlyCache,
|
||||||
PreferCache,
|
PreferCache,
|
||||||
PreferNetwork,
|
PreferNetwork,
|
||||||
|
@ -1743,18 +1743,18 @@ export class CoreSitesProvider {
|
||||||
* @param strategy Reading strategy.
|
* @param strategy Reading strategy.
|
||||||
* @return PreSets options object.
|
* @return PreSets options object.
|
||||||
*/
|
*/
|
||||||
getReadingStrategyPreSets(strategy: ReadingStrategy): CoreSiteWSPreSets {
|
getReadingStrategyPreSets(strategy: CoreSitesReadingStrategy): CoreSiteWSPreSets {
|
||||||
switch (strategy) {
|
switch (strategy) {
|
||||||
case ReadingStrategy.PreferCache:
|
case CoreSitesReadingStrategy.PreferCache:
|
||||||
return {
|
return {
|
||||||
omitExpires: true,
|
omitExpires: true,
|
||||||
};
|
};
|
||||||
case ReadingStrategy.OnlyCache:
|
case CoreSitesReadingStrategy.OnlyCache:
|
||||||
return {
|
return {
|
||||||
omitExpires: true,
|
omitExpires: true,
|
||||||
forceOffline: true,
|
forceOffline: true,
|
||||||
};
|
};
|
||||||
case ReadingStrategy.PreferNetwork:
|
case CoreSitesReadingStrategy.PreferNetwork:
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue