Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/addon/block/myoverview/providers/block-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class AddonBlockMyOverviewHandler extends CoreBlockBaseHandler {
* @return Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.6') ||
return (this.sitesProvider.getCurrentSite() && this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.6')) ||
!this.coursesProvider.isMyCoursesDisabledInSite();
}

Expand Down
4 changes: 3 additions & 1 deletion src/addon/block/timeline/providers/block-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class AddonBlockTimelineHandler extends CoreBlockBaseHandler {
*/
isEnabled(): boolean | Promise<boolean> {
return this.timelineProvider.isAvailable().then((enabled) => {
return enabled && (this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.6') ||
const currentSite = this.sitesProvider.getCurrentSite();

return enabled && ((currentSite && currentSite.isVersionGreaterEqualThan('3.6')) ||
!this.coursesProvider.isMyCoursesDisabledInSite());
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/addon/calendar/providers/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export class AddonCalendarProvider {
site = site || this.sitesProvider.getCurrentSite();

// The WS to create/edit events requires a fix that was integrated in 3.7.1.
return site.isVersionGreaterEqualThan('3.7.1');
return site && site.isVersionGreaterEqualThan('3.7.1');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/addon/filter/multilang/providers/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ export class AddonFilterMultilangHandler extends CoreFilterDefaultHandler {
*/
shouldBeApplied(options: CoreFilterFormatTextOptions, site?: CoreSite): boolean {
// The filter should be applied if site is older than 3.7 or the WS didn't filter the text.
return options.wsNotFiltered || !site.isVersionGreaterEqualThan('3.7');
return options.wsNotFiltered || (site && !site.isVersionGreaterEqualThan('3.7'));
}
}
7 changes: 5 additions & 2 deletions src/addon/mod/assign/components/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo

// Check if groupmode is enabled to avoid showing wrong numbers.
return this.groupsProvider.getActivityGroupInfo(this.assign.cmid, false).then((groupInfo) => {
const currentSite = this.sitesProvider.getCurrentSite();
this.groupInfo = groupInfo;
this.showNumbers = groupInfo.groups.length == 0 ||
this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.5');
(currentSite && currentSite.isVersionGreaterEqualThan('3.5'));

return this.setGroup(this.groupsProvider.validateGroupId(this.group, groupInfo));
});
Expand Down Expand Up @@ -258,8 +259,10 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
}
}

const currentSite = this.sitesProvider.getCurrentSite();

this.needsGradingAvalaible = response.gradingsummary && response.gradingsummary.submissionsneedgradingcount > 0 &&
this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.2');
currentSite && currentSite.isVersionGreaterEqualThan('3.2');
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class AddonModAssignSubmissionOnlineTextHandler implements AddonModAssign
// Bug was fixed in 3.1.1 minor release and in 3.2.
const currentSite = this.sitesProvider.getCurrentSite();

return currentSite.isVersionGreaterEqualThan('3.1.1') || currentSite.checkIfAppUsesLocalMobile();
return currentSite && (currentSite.isVersionGreaterEqualThan('3.1.1') || currentSite.checkIfAppUsesLocalMobile());
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/addon/mod/forum/providers/forum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ export class AddonModForumProvider {
* @return True if fixed, false otherwise.
*/
isAllParticipantsFixed(): boolean {
return this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan(['3.1.5', '3.2.2']);
return this.sitesProvider.getCurrentSite() &&
this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan(['3.1.5', '3.2.2']);
}

/**
Expand Down Expand Up @@ -543,7 +544,7 @@ export class AddonModForumProvider {
isDiscussionListSortingAvailable(site?: CoreSite): boolean {
site = site || this.sitesProvider.getCurrentSite();

return site.isVersionGreaterEqualThan('3.7');
return site && site.isVersionGreaterEqualThan('3.7');
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/addon/mod/forum/providers/prefetch-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export class AddonModForumPrefetchHandler extends CoreCourseActivityPrefetchHand
*/
protected getPostsFiles(posts: any[]): any[] {
let files = [];
const getInlineFiles = this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.2');
const getInlineFiles = this.sitesProvider.getCurrentSite() &&
this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.2');

posts.forEach((post) => {
if (post.attachments && post.attachments.length) {
Expand Down
3 changes: 2 additions & 1 deletion src/addon/mod/glossary/providers/prefetch-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export class AddonModGlossaryPrefetchHandler extends CoreCourseActivityPrefetchH
*/
protected getFilesFromGlossaryAndEntries(module: any, glossary: any, entries: any[]): any[] {
let files = this.getIntroFilesFromInstance(module, glossary);
const getInlineFiles = this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.2');
const getInlineFiles = this.sitesProvider.getCurrentSite() &&
this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.2');

// Get entries files.
entries.forEach((entry) => {
Expand Down
5 changes: 3 additions & 2 deletions src/addon/mod/quiz/providers/prefetch-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ export class AddonModQuizPrefetchHandler extends CoreCourseActivityPrefetchHandl
*/
protected getAttemptsFeedbackFiles(quiz: any, attempts: any[]): Promise<any[]> {
// We have quiz data, now we'll get specific data for each attempt.
const promises = [],
getInlineFiles = this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.2');
const promises = [];
const getInlineFiles = this.sitesProvider.getCurrentSite() &&
this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.2');
let files = [];

attempts.forEach((attempt) => {
Expand Down
4 changes: 3 additions & 1 deletion src/addon/mod/resource/providers/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ export class AddonModResourceHelperProvider {
* @return Whether the resource should be displayed embeded.
*/
isDisplayedEmbedded(module: any, display: number): boolean {
const currentSite = this.sitesProvider.getCurrentSite();

if ((!module.contents.length && !module.contentsinfo) || !this.fileProvider.isAvailable() ||
(!this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7') && this.isNextcloudFile(module))) {
(currentSite && !currentSite.isVersionGreaterEqualThan('3.7') && this.isNextcloudFile(module))) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/addon/mod/resource/providers/prefetch-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class AddonModResourcePrefetchHandler extends CoreCourseResourcePrefetchH
* @return Promise resolved with true if downloadable, resolved with false otherwise.
*/
isDownloadable(module: any, courseId: number): Promise<boolean> {
if (this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
if (this.sitesProvider.getCurrentSite() && this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
// Nextcloud files are downloadable from 3.7 onwards.
return Promise.resolve(true);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/course/providers/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class CoreCourseProvider {
canGetCourseBlocks(site?: CoreSite): boolean {
site = site || this.sitesProvider.getCurrentSite();

return site.isVersionGreaterEqualThan('3.7') && site.wsAvailable('core_block_get_course_blocks');
return site && site.isVersionGreaterEqualThan('3.7') && site.wsAvailable('core_block_get_course_blocks');
}

/**
Expand All @@ -135,7 +135,7 @@ export class CoreCourseProvider {
canRequestStealthModules(site?: CoreSite): boolean {
site = site || this.sitesProvider.getCurrentSite();

return site.isVersionGreaterEqualThan(['3.4.6', '3.5.3']);
return site && site.isVersionGreaterEqualThan(['3.4.6', '3.5.3']);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/core/course/providers/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ export class CoreCourseSyncProvider extends CoreSyncBaseProvider {
if (result.updated) {
// Update data.
return this.courseProvider.invalidateSections(courseId, siteId).then(() => {
if (this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.6')) {
const currentSite = this.sitesProvider.getCurrentSite();

if (currentSite && currentSite.isVersionGreaterEqualThan('3.6')) {
return this.courseProvider.getSections(courseId, false, true, undefined, siteId);
} else {
return this.courseProvider.getActivitiesCompletionStatus(courseId, siteId);
Expand Down
4 changes: 2 additions & 2 deletions src/core/courses/pages/course-preview/course-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
});
});
}).finally(() => {
if (!this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
if (this.sitesProvider.getCurrentSite() && !this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
return this.coursesProvider.isGetCoursesByFieldAvailableInSite().then((available) => {
if (available) {
return this.coursesProvider.getCourseByField('id', this.course.id).then((course) => {
Expand Down Expand Up @@ -402,7 +402,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
promises.push(this.coursesProvider.invalidateCourse(this.course.id));
promises.push(this.coursesProvider.invalidateCourseEnrolmentMethods(this.course.id));
promises.push(this.courseOptionsDelegate.clearAndInvalidateCoursesOptions(this.course.id));
if (this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
if (this.sitesProvider.getCurrentSite() && !this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.7')) {
promises.push(this.coursesProvider.invalidateCoursesByField('id', this.course.id));
}
if (this.guestInstanceId) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/courses/providers/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class CoreCoursesHelperProvider {
promises = [],
colors = [];

if (site.isVersionGreaterEqualThan('3.8')) {
if (site && site.isVersionGreaterEqualThan('3.8')) {
promises.push(site.getConfig().then((configs) => {
for (let x = 0; x < 10; x++) {
colors[x] = configs['core_admin_coursecolor' + (x + 1)] || null;
Expand Down
2 changes: 1 addition & 1 deletion src/directives/format-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ export class CoreFormatTextDirective implements OnChanges {
}

// Width and height parameters are required in 3.6 and older sites.
if (!site.isVersionGreaterEqualThan('3.7')) {
if (site && !site.isVersionGreaterEqualThan('3.7')) {
newUrl += '&width=' + width + '&height=' + height;
}
iframe.src = newUrl;
Expand Down