From 68a4a4e75f6112d550afe67af8cafd0e4ddac5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 31 Aug 2022 13:36:05 +0200 Subject: [PATCH] MOBILE-4081 chore: Fixtures on types and async functions --- .../calendar/addon-calendar-calendar.html | 2 +- .../calendar/services/calendar-helper.ts | 4 +- src/addons/calendar/services/calendar.ts | 2 +- .../messages/pages/discussion/discussion.html | 2 +- .../mod/assign/classes/submissions-source.ts | 2 +- .../components/submission/submission.ts | 2 +- src/addons/mod/assign/services/assign.ts | 2 +- src/addons/mod/chat/pages/chat/chat.ts | 2 +- src/addons/mod/chat/services/chat-helper.ts | 4 +- src/addons/mod/data/services/data-helper.ts | 2 +- src/addons/mod/data/services/data.ts | 2 +- .../mod/feedback/pages/attempt/attempt.ts | 4 +- .../forum/classes/forum-discussions-source.ts | 2 +- .../forum/pages/discussion/discussion.page.ts | 4 +- .../mod/glossary/components/index/index.ts | 2 +- src/addons/mod/glossary/services/glossary.ts | 14 +++- .../mod/h5pactivity/components/index/index.ts | 2 +- .../pages/attempt-results/attempt-results.ts | 2 +- .../pages/user-attempts/user-attempts.ts | 2 +- .../mod/lesson/services/handlers/prefetch.ts | 15 ++-- src/addons/mod/lti/services/lti-helper.ts | 2 +- .../index/addon-mod-wiki-index.html | 2 +- src/addons/mod/wiki/services/wiki.ts | 2 +- .../assessment-strategy.ts | 4 +- src/core/components/icon/icon.scss | 1 - .../block/classes/base-block-component.ts | 4 +- .../courses/services/handlers/course-link.ts | 23 ++--- .../rich-text-editor/rich-text-editor.ts | 2 +- .../editor/services/editor-offline.ts | 6 +- .../services/fileuploader-helper.ts | 2 +- .../grades/services/handlers/report-link.ts | 18 +--- .../grades/services/handlers/user-link.ts | 18 +--- .../features/h5p/classes/content-validator.ts | 13 ++- src/core/features/h5p/classes/core.ts | 2 +- src/core/features/h5p/classes/file-storage.ts | 4 +- src/core/features/h5p/classes/helper.ts | 2 +- src/core/features/h5p/classes/validator.ts | 2 +- .../h5p/components/h5p-player/h5p-player.ts | 13 ++- .../login/components/site-help/site-help.html | 12 +-- src/core/features/login/pages/site/site.ts | 4 +- .../services/pushnotifications.ts | 9 +- src/core/features/rating/services/rating.ts | 12 ++- .../sitehome/services/handlers/index-link.ts | 5 +- src/core/features/user/pages/about/about.scss | 4 +- .../features/user/pages/profile/profile.scss | 2 +- .../user/services/handlers/profile-link.ts | 23 +---- .../services/user-profile-field-delegate.ts | 2 +- src/core/pipes/format-date.ts | 4 +- src/core/services/file.ts | 2 +- src/core/services/filepool.ts | 2 +- src/core/services/plugin-file-delegate.ts | 6 +- src/core/services/utils/mimetype.ts | 13 ++- src/core/services/utils/text.ts | 11 +-- src/core/services/utils/time.ts | 2 +- src/core/services/utils/url.ts | 2 +- src/core/services/utils/utils.ts | 84 +++++++++---------- 56 files changed, 159 insertions(+), 233 deletions(-) diff --git a/src/addons/calendar/components/calendar/addon-calendar-calendar.html b/src/addons/calendar/components/calendar/addon-calendar-calendar.html index 21d0bc83d..b355dd1e5 100644 --- a/src/addons/calendar/components/calendar/addon-calendar-calendar.html +++ b/src/addons/calendar/components/calendar/addon-calendar-calendar.html @@ -93,7 +93,7 @@

- {{ 'core.nummore' | translate:{$a: day.filteredEvents.length - 3} }} + {{ 'core.nummore' | translate:{$a: day.filteredEvents.length - 3} }}

diff --git a/src/addons/calendar/services/calendar-helper.ts b/src/addons/calendar/services/calendar-helper.ts index 95366cf1a..09b58b831 100644 --- a/src/addons/calendar/services/calendar-helper.ts +++ b/src/addons/calendar/services/calendar-helper.ts @@ -661,7 +661,7 @@ export class AddonCalendarHelperProvider { const finalPromises: Promise[] =[AddonCalendar.invalidateAllUpcomingEvents()]; // Fetch months and days. - fetchTimestarts.map((fetchTime) => { + fetchTimestarts.forEach((fetchTime) => { const day = moment(fetchTime * 1000); const monthId = this.getMonthId(day); @@ -697,7 +697,7 @@ export class AddonCalendarHelperProvider { }); // Invalidate months and days. - invalidateTimestarts.map((fetchTime) => { + invalidateTimestarts.forEach((fetchTime) => { const day = moment(fetchTime * 1000); const monthId = this.getMonthId(day); diff --git a/src/addons/calendar/services/calendar.ts b/src/addons/calendar/services/calendar.ts index 155861284..5e0f7e811 100644 --- a/src/addons/calendar/services/calendar.ts +++ b/src/addons/calendar/services/calendar.ts @@ -529,7 +529,7 @@ export class AddonCalendarProvider { // Convert the array to an object. const result = {}; if (response.allowedeventtypes) { - response.allowedeventtypes.map((type) => { + response.allowedeventtypes.forEach((type) => { result[type] = true; }); } diff --git a/src/addons/messages/pages/discussion/discussion.html b/src/addons/messages/pages/discussion/discussion.html index f5c3e8dba..d0c876da3 100644 --- a/src/addons/messages/pages/discussion/discussion.html +++ b/src/addons/messages/pages/discussion/discussion.html @@ -65,7 +65,7 @@

{{ 'addon.messages.selfconversation' | translate }}

-

{{ 'addon.messages.selfconversationdefaultmessage' | translate }}

+

{{ 'addon.messages.selfconversationdefaultmessage' | translate }}

{{ title }}

diff --git a/src/addons/mod/assign/classes/submissions-source.ts b/src/addons/mod/assign/classes/submissions-source.ts index 8a5ef3441..273867191 100644 --- a/src/addons/mod/assign/classes/submissions-source.ts +++ b/src/addons/mod/assign/classes/submissions-source.ts @@ -126,7 +126,7 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc CoreSites.getCurrentSiteId(), ); } - } catch (error) { + } catch { // Ignore errors, probably user is offline or sync is blocked. } } diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index 7e040d205..d38e423ac 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -525,7 +525,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can submitId: this.submitId, }, this.siteId); } - } catch (error) { + } catch { // Ignore errors, probably user is offline or sync is blocked. } } diff --git a/src/addons/mod/assign/services/assign.ts b/src/addons/mod/assign/services/assign.ts index 2b313ceaa..c09110175 100644 --- a/src/addons/mod/assign/services/assign.ts +++ b/src/addons/mod/assign/services/assign.ts @@ -565,7 +565,7 @@ export class AddonModAssignProvider { }; try { - return this.getSubmissionStatus(assign.id, newOptions); + return await this.getSubmissionStatus(assign.id, newOptions); } catch { // Error, return the first result even if it doesn't have the user submission. return response; diff --git a/src/addons/mod/chat/pages/chat/chat.ts b/src/addons/mod/chat/pages/chat/chat.ts index 0fce55789..76a53a6a4 100644 --- a/src/addons/mod/chat/pages/chat/chat.ts +++ b/src/addons/mod/chat/pages/chat/chat.ts @@ -220,7 +220,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { } return id; - } catch (error) { + } catch { // Ignore errors. return id; } diff --git a/src/addons/mod/chat/services/chat-helper.ts b/src/addons/mod/chat/services/chat-helper.ts index 2f4f6e02d..5ec95bdaa 100644 --- a/src/addons/mod/chat/services/chat-helper.ts +++ b/src/addons/mod/chat/services/chat-helper.ts @@ -66,7 +66,9 @@ export class AddonModChatHelperProvider { if (!formattedMessage.special && formattedMessage.message.match(patternTo)) { const matches = formattedMessage.message.match(patternTo); - formattedMessage.message = `${Translate.instant('addon.mod_chat.saidto')} ${matches![1]}: ${matches![2]}`; + formattedMessage.message = ` + ${Translate.instant('addon.mod_chat.saidto')} + ${matches![1]}: ${matches![2]}`; } formattedMessage.showUserData = this.showUserData(currentUserId, message, prevMessage); diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts index 6993f0210..258b15bf2 100644 --- a/src/addons/mod/data/services/data-helper.ts +++ b/src/addons/mod/data/services/data-helper.ts @@ -723,7 +723,7 @@ export class AddonModDataHelperProvider { try { await AddonModData.invalidateEntryData(dataId, entryId, siteId); await AddonModData.invalidateEntriesData(dataId, siteId); - } catch (error) { + } catch { // Ignore errors. } diff --git a/src/addons/mod/data/services/data.ts b/src/addons/mod/data/services/data.ts index dde8919c8..09275a88a 100644 --- a/src/addons/mod/data/services/data.ts +++ b/src/addons/mod/data/services/data.ts @@ -987,7 +987,7 @@ export class AddonModDataProvider { 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; options.readingStrategy = options.readingStrategy || CoreSitesReadingStrategy.PREFER_NETWORK; diff --git a/src/addons/mod/feedback/pages/attempt/attempt.ts b/src/addons/mod/feedback/pages/attempt/attempt.ts index e8981da89..c83b91289 100644 --- a/src/addons/mod/feedback/pages/attempt/attempt.ts +++ b/src/addons/mod/feedback/pages/attempt/attempt.ts @@ -66,9 +66,9 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy { /** * @inheritdoc */ - ngOnInit(): void { + async ngOnInit(): Promise { try { - this.attempts.start(); + await this.attempts.start(); } catch (error) { CoreDomUtils.showErrorModal(error); diff --git a/src/addons/mod/forum/classes/forum-discussions-source.ts b/src/addons/mod/forum/classes/forum-discussions-source.ts index f525f4d02..49b12fa60 100644 --- a/src/addons/mod/forum/classes/forum-discussions-source.ts +++ b/src/addons/mod/forum/classes/forum-discussions-source.ts @@ -292,7 +292,7 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource discussion.userfullname = user.fullname; discussion.userpictureurl = user.profileimageurl; - } catch (error) { + } catch { // Ignore errors. } }); diff --git a/src/addons/mod/forum/pages/discussion/discussion.page.ts b/src/addons/mod/forum/pages/discussion/discussion.page.ts index 6556402dd..dafc9525d 100644 --- a/src/addons/mod/forum/pages/discussion/discussion.page.ts +++ b/src/addons/mod/forum/pages/discussion/discussion.page.ts @@ -358,7 +358,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes // Not set, use default sort. // @TODO add fallback to $CFG->forum_displaymode. } - } catch (error) { + } catch { // Ignore errors. } } @@ -511,7 +511,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes } await Promise.all(promises); - } catch (error) { + } catch { // Ignore errors. } diff --git a/src/addons/mod/glossary/components/index/index.ts b/src/addons/mod/glossary/components/index/index.ts index 36595994c..523c6ffa2 100644 --- a/src/addons/mod/glossary/components/index/index.ts +++ b/src/addons/mod/glossary/components/index/index.ts @@ -474,7 +474,7 @@ class AddonModGlossaryEntriesManager extends CoreListItemsManager => { - const result = await fetchFunction({ + const result = fetchFunction({ from: entries.length, ...options, // Include all options. }); @@ -915,7 +914,14 @@ export class AddonModGlossaryProvider { try { // Try to add it in online. - return this.addEntryOnline(glossaryId, concept, definition, entryOptions, attachments, otherOptions.siteId); + return await this.addEntryOnline( + glossaryId, + concept, + definition, + entryOptions, + attachments, + otherOptions.siteId, + ); } catch (error) { if (otherOptions.allowOffline && !CoreUtils.isWebServiceError(error)) { // Couldn't connect to server, store in offline. diff --git a/src/addons/mod/h5pactivity/components/index/index.ts b/src/addons/mod/h5pactivity/components/index/index.ts index b1808e316..74e0277b2 100644 --- a/src/addons/mod/h5pactivity/components/index/index.ts +++ b/src/addons/mod/h5pactivity/components/index/index.ts @@ -459,7 +459,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv try { // Invalidate attempts. await AddonModH5PActivity.invalidateUserAttempts(this.h5pActivity.id, undefined, this.siteId); - } catch (error) { + } catch { // Ignore errors. } diff --git a/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts b/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts index 3b3727a2b..552568111 100644 --- a/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts +++ b/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts @@ -119,7 +119,7 @@ export class AddonModH5PActivityAttemptResultsPage implements OnInit { try { this.user = await CoreUser.getProfile(this.attempt.userid, this.courseId, true); - } catch (error) { + } catch { // Ignore errors. } } diff --git a/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts b/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts index bb95f9fcb..c0864d3ec 100644 --- a/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts +++ b/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts @@ -133,7 +133,7 @@ export class AddonModH5PActivityUserAttemptsPage implements OnInit { protected async fetchUserProfile(): Promise { try { this.user = await CoreUser.getProfile(this.userId, this.courseId, true); - } catch (error) { + } catch { // Ignore errors. } } diff --git a/src/addons/mod/lesson/services/handlers/prefetch.ts b/src/addons/mod/lesson/services/handlers/prefetch.ts index 4d87bf1ce..011b47b40 100644 --- a/src/addons/mod/lesson/services/handlers/prefetch.ts +++ b/src/addons/mod/lesson/services/handlers/prefetch.ts @@ -143,7 +143,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref if (password) { try { - return this.validatePassword(lessonId, accessInfo, password, options); + return await this.validatePassword(lessonId, accessInfo, password, options); } catch { // Error validating it. } @@ -320,7 +320,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref * @param lesson Lesson. * @param password Password (if needed). * @param retake Retake to prefetch. - * @param options Options. + * @param modOptions Options. * @return Promise resolved when done. */ protected async prefetchPlayData( @@ -364,12 +364,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref const promises = pages.map(async (data) => { // Check if any page has a RANDOMBRANCH jump. if (!hasRandomBranch) { - for (let i = 0; i < data.jumps.length; i++) { - if (data.jumps[i] == AddonModLessonProvider.LESSON_RANDOMBRANCH) { - hasRandomBranch = true; - break; - } - } + hasRandomBranch = data.jumps.some((jump) => jump === AddonModLessonProvider.LESSON_RANDOMBRANCH); } // Get the page data. We don't pass accessInfo because we don't need to calculate the offline data. @@ -499,8 +494,8 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref * Validate the password. * * @param lessonId Lesson ID. - * @param info Lesson access info. - * @param pwd Password to check. + * @param accessInfo Lesson access info. + * @param password Password to check. * @param options Other options. * @return Promise resolved when done. */ diff --git a/src/addons/mod/lti/services/lti-helper.ts b/src/addons/mod/lti/services/lti-helper.ts index dcb3ac154..b23cda06a 100644 --- a/src/addons/mod/lti/services/lti-helper.ts +++ b/src/addons/mod/lti/services/lti-helper.ts @@ -118,7 +118,7 @@ export class AddonModLtiHelperProvider { await AddonModLti.logView(ltiId, name, siteId); CoreCourse.checkModuleCompletion(courseId, module.completiondata); - } catch (error) { + } catch { // Ignore errors. } } diff --git a/src/addons/mod/wiki/components/index/addon-mod-wiki-index.html b/src/addons/mod/wiki/components/index/addon-mod-wiki-index.html index 56336ba50..c6e278efb 100644 --- a/src/addons/mod/wiki/components/index/addon-mod-wiki-index.html +++ b/src/addons/mod/wiki/components/index/addon-mod-wiki-index.html @@ -65,7 +65,7 @@
- {{ 'core.tag.tags' | translate }}: + {{ 'core.tag.tags' | translate }}:
diff --git a/src/addons/mod/wiki/services/wiki.ts b/src/addons/mod/wiki/services/wiki.ts index d83357c88..32180ffb9 100644 --- a/src/addons/mod/wiki/services/wiki.ts +++ b/src/addons/mod/wiki/services/wiki.ts @@ -723,7 +723,7 @@ export class AddonModWikiProvider { try { // Try to create it in online. - return this.newPageOnline(title, content, options); + return await this.newPageOnline(title, content, options); } catch (error) { if (CoreUtils.isWebServiceError(error)) { // The WebService has thrown an error, this means that the page cannot be added. diff --git a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts index 26d9b61c1..78b028706 100644 --- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts +++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts @@ -119,7 +119,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe // Load Weights selector. if (this.edit && this.access.canallocate) { - this.weights; + this.weights = []; for (let i = 16; i >= 0; i--) { this.weights[i] = i; } @@ -347,8 +347,6 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe this.workshop.course, assessmentData, ); - - gradeUpdated = false; } else { // Try to send it to server. diff --git a/src/core/components/icon/icon.scss b/src/core/components/icon/icon.scss index 097de22a6..cc3176c14 100644 --- a/src/core/components/icon/icon.scss +++ b/src/core/components/icon/icon.scss @@ -8,7 +8,6 @@ :host-context(ion-item.md) ion-icon { &[slot] { - font-size: 1.6em; color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.54); font-size: 24px; margin-top: 12px; diff --git a/src/core/features/block/classes/base-block-component.ts b/src/core/features/block/classes/base-block-component.ts index b73e0e517..58d3878ab 100644 --- a/src/core/features/block/classes/base-block-component.ts +++ b/src/core/features/block/classes/base-block-component.ts @@ -52,10 +52,8 @@ export abstract class CoreBlockBaseComponent implements OnInit, ICoreBlockCompon */ async ngOnInit(): Promise { if (this.block.configs && this.block.configs.length > 0) { - this.block.configs.map((config) => { + this.block.configs.forEach((config) => { config.value = CoreTextUtils.parseJSON(config.value); - - return config; }); this.block.configsRecord = CoreUtils.arrayToObject(this.block.configs, 'name'); diff --git a/src/core/features/courses/services/handlers/course-link.ts b/src/core/features/courses/services/handlers/course-link.ts index 5c7347844..0bd9d0229 100644 --- a/src/core/features/courses/services/handlers/course-link.ts +++ b/src/core/features/courses/services/handlers/course-link.ts @@ -47,13 +47,7 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler } /** - * Get the list of actions for a link (url). - * - * @param siteIds List of sites the URL belongs to. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @return List of (or promise resolved with list of) actions. + * @inheritdoc */ getActions( siteIds: string[], @@ -103,17 +97,10 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler } /** - * Check if the handler is enabled for a certain site (site + user) and a URL. - * If not defined, defaults to true. - * - * @param siteId The site ID. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @return Whether the handler is enabled for the URL and site. + * @inheritdoc */ - async isEnabled(siteId: string, url: string, params: Params, courseId?: number): Promise { - courseId = parseInt(params.id, 10); + async isEnabled(siteId: string, url: string, params: Params): Promise { + const courseId = parseInt(params.id, 10); if (!courseId) { return false; @@ -333,7 +320,7 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler await CoreUtils.wait(5000); - return await this.waitForEnrolled(courseId); + return this.waitForEnrolled(courseId); } } diff --git a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts index 44a06bb56..ac0ceebf9 100644 --- a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts +++ b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts @@ -973,7 +973,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, this.showMessage('core.editor.textrecovered', this.RESTORE_MESSAGE_CLEAR_TIME); } } - } catch (error) { + } catch { // Ignore errors, shouldn't happen. } } diff --git a/src/core/features/editor/services/editor-offline.ts b/src/core/features/editor/services/editor-offline.ts index 810893090..0025f84e4 100644 --- a/src/core/features/editor/services/editor-offline.ts +++ b/src/core/features/editor/services/editor-offline.ts @@ -56,7 +56,7 @@ export class CoreEditorOfflineProvider { const params = this.fixDraftPrimaryData(contextLevel, contextInstanceId, elementId, extraParams); await db.deleteRecords(DRAFT_TABLE, params); - } catch (error) { + } catch { // Ignore errors, probably no draft stored. } } @@ -149,12 +149,12 @@ export class CoreEditorOfflineProvider { } await db.insertRecord(DRAFT_TABLE, entry); - } catch (error) { + } catch { // Ignore errors saving the draft. It shouldn't happen. } return entry; - } catch (error) { + } catch { // No draft stored. Store an empty draft to save the pageinstance. await this.saveDraft( contextLevel, diff --git a/src/core/features/fileuploader/services/fileuploader-helper.ts b/src/core/features/fileuploader/services/fileuploader-helper.ts index 6f160a070..ab401b17c 100644 --- a/src/core/features/fileuploader/services/fileuploader-helper.ts +++ b/src/core/features/fileuploader/services/fileuploader-helper.ts @@ -812,7 +812,7 @@ export class CoreFileUploaderHelperProvider { file = await CoreFile.getFileObjectFromFileEntry(fileEntry); size = file.size; - } catch (error) { + } catch { // Ignore failures. } } diff --git a/src/core/features/grades/services/handlers/report-link.ts b/src/core/features/grades/services/handlers/report-link.ts index 1efed0df7..a6457e3a9 100644 --- a/src/core/features/grades/services/handlers/report-link.ts +++ b/src/core/features/grades/services/handlers/report-link.ts @@ -30,14 +30,7 @@ export class CoreGradesReportLinkHandlerService extends CoreContentLinksHandlerB pattern = /\/grade\/report(\/user)?\/index.php/; /** - * Get the list of actions for a link (url). - * - * @param siteIds List of sites the URL belongs to. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @param data Extra data to handle the URL. - * @return List of (or promise resolved with list of) actions. + * @inheritdoc */ getActions( siteIds: string[], @@ -60,14 +53,7 @@ export class CoreGradesReportLinkHandlerService extends CoreContentLinksHandlerB } /** - * Check if the handler is enabled for a certain site (site + user) and a URL. - * If not defined, defaults to true. - * - * @param siteId The site ID. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @return Whether the handler is enabled for the URL and site. + * @inheritdoc */ async isEnabled(siteId: string, url: string, params: Record, courseId?: number): Promise { if (!courseId && !params.id) { diff --git a/src/core/features/grades/services/handlers/user-link.ts b/src/core/features/grades/services/handlers/user-link.ts index 1f1ba4008..b3fd56690 100644 --- a/src/core/features/grades/services/handlers/user-link.ts +++ b/src/core/features/grades/services/handlers/user-link.ts @@ -30,14 +30,7 @@ export class CoreGradesUserLinkHandlerService extends CoreContentLinksHandlerBas pattern = /\/course\/user\.php.*[?&]mode=grade/; /** - * Get the list of actions for a link (url). - * - * @param siteIds List of sites the URL belongs to. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @param data Extra data to handle the URL. - * @return List of (or promise resolved with list of) actions. + * @inheritdoc */ getActions( siteIds: string[], @@ -60,14 +53,7 @@ export class CoreGradesUserLinkHandlerService extends CoreContentLinksHandlerBas } /** - * Check if the handler is enabled for a certain site (site + user) and a URL. - * If not defined, defaults to true. - * - * @param siteId The site ID. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @return Whether the handler is enabled for the URL and site. + * @inheritdoc */ async isEnabled(siteId: string, url: string, params: Record, courseId?: number): Promise { if (!courseId && !params.id) { diff --git a/src/core/features/h5p/classes/content-validator.ts b/src/core/features/h5p/classes/content-validator.ts index 20c2cb69b..b2861a8f0 100644 --- a/src/core/features/h5p/classes/content-validator.ts +++ b/src/core/features/h5p/classes/content-validator.ts @@ -191,7 +191,7 @@ export class CoreH5PContentValidator { /** * Validate given value against number semantics. * - * @param num Number to validate. + * @param value Number to validate. * @param semantics Semantics. * @return Validated number. */ @@ -497,9 +497,7 @@ export class CoreH5PContentValidator { let validateFunction: undefined | ((...args: unknown[]) => unknown); let field: CoreH5PSemantics | undefined; - for (let i = 0; i < semantics.fields.length; i++) { - field = semantics.fields[i]; - + for (const field of semantics.fields) { if (field.name == key) { if (semantics.optional) { field.optional = true; @@ -778,8 +776,7 @@ export class CoreH5PContentValidator { if (matches && matches.length > 1) { if (allowedStyles && attrName === 'style') { // Allow certain styles. - for (let i = 0; i < allowedStyles.length; i++) { - const pattern = allowedStyles[i]; + for (const pattern of allowedStyles) { if (matches[1].match(pattern)) { // All patterns are start to end patterns, and CKEditor adds one span per style. attrArray.push('style="' + matches[1] + '"'); @@ -1122,7 +1119,7 @@ export class CoreH5PContentValidator { }, ]; - return this.metadataSemantics!; + return this.metadataSemantics; } /** @@ -1266,7 +1263,7 @@ export class CoreH5PContentValidator { ], }; - return this.copyrightSemantics!; + return this.copyrightSemantics; } /** diff --git a/src/core/features/h5p/classes/core.ts b/src/core/features/h5p/classes/core.ts index 8c50ea5eb..e77c7c752 100644 --- a/src/core/features/h5p/classes/core.ts +++ b/src/core/features/h5p/classes/core.ts @@ -292,7 +292,7 @@ export class CoreH5PCore { // Update library usage. try { await this.h5pFramework.deleteLibraryUsage(content.id, siteId); - } catch (error) { + } catch { // Ignore errors. } diff --git a/src/core/features/h5p/classes/file-storage.ts b/src/core/features/h5p/classes/file-storage.ts index 5bbab236d..598e4a404 100644 --- a/src/core/features/h5p/classes/file-storage.ts +++ b/src/core/features/h5p/classes/file-storage.ts @@ -229,7 +229,7 @@ export class CoreH5PFileStorage { try { // Delete the index.html. await this.deleteContentIndex(entry.foldername, site.getId()); - } catch (error) { + } catch { // Ignore errors. } }); @@ -463,7 +463,7 @@ export class CoreH5PFileStorage { // Delete existing library version. try { await CoreFile.removeDir(folderPath); - } catch (error) { + } catch { // Ignore errors, maybe it doesn't exist. } diff --git a/src/core/features/h5p/classes/helper.ts b/src/core/features/h5p/classes/helper.ts index d418fa615..126ee649f 100644 --- a/src/core/features/h5p/classes/helper.ts +++ b/src/core/features/h5p/classes/helper.ts @@ -223,7 +223,7 @@ export class CoreH5PHelper { // Remove tmp folder. try { await CoreFile.removeDir(destFolder); - } catch (error) { + } catch { // Ignore errors, it will be deleted eventually. } } diff --git a/src/core/features/h5p/classes/validator.ts b/src/core/features/h5p/classes/validator.ts index edc952aa2..7eca0f96f 100644 --- a/src/core/features/h5p/classes/validator.ts +++ b/src/core/features/h5p/classes/validator.ts @@ -273,7 +273,7 @@ export class CoreH5PValidator { const parts = entry.name.split('.'); // The language code is in parts[0]. langIndex[parts[0]] = langFileData; - } catch (error) { + } catch { // Ignore this language. } })); diff --git a/src/core/features/h5p/components/h5p-player/h5p-player.ts b/src/core/features/h5p/components/h5p-player/h5p-player.ts index dfc86f0b4..2d727e8af 100644 --- a/src/core/features/h5p/components/h5p-player/h5p-player.ts +++ b/src/core/features/h5p/components/h5p-player/h5p-player.ts @@ -47,7 +47,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { canDownload$ = new BehaviorSubject(false); calculating$ = new BehaviorSubject(true); displayOptions?: CoreH5PDisplayOptions; - urlParams?: {[name: string]: string}; + urlParams: {[name: string]: string} = {}; protected site: CoreSite; protected siteId: string; @@ -60,7 +60,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { ) { this.logger = CoreLogger.getInstance('CoreH5PPlayerComponent'); - this.site = CoreSites.getCurrentSite()!; + this.site = CoreSites.getRequiredCurrentSite(); this.siteId = this.site.getId(); this.siteCanDownload = this.site.canDownloadFiles() && !CoreH5P.isOfflineDisabledInSite(); } @@ -100,7 +100,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { // Download the package in background if the size is low. try { - this.attemptDownloadInBg(); + await this.attemptDownloadInBg(); } catch (error) { this.logger.error('Error downloading H5P in background', error); } @@ -120,12 +120,12 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { try { // Get the file size and ask the user to confirm. - const size = await CorePluginFileDelegate.getFileSize({ fileurl: this.urlParams!.url }, this.siteId); + const size = await CorePluginFileDelegate.getFileSize({ fileurl: this.urlParams.url }, this.siteId); await CoreDomUtils.confirmDownloadSize({ size: size, total: true }); // User confirmed, add to the queue. - await CoreFilepool.addToQueueByUrl(this.siteId, this.urlParams!.url, this.component, this.componentId); + await CoreFilepool.addToQueueByUrl(this.siteId, this.urlParams.url, this.component, this.componentId); } catch (error) { if (CoreDomUtils.isCanceledError(error)) { @@ -191,7 +191,6 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { /** * Calculate state of the file. * - * @param fileUrl The H5P file URL. * @return Promise resolved when done. */ protected async calculateState(): Promise { @@ -199,7 +198,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { // Get the status of the file. try { - const state = await CoreFilepool.getFileStateByUrl(this.siteId, this.urlParams!.url); + const state = await CoreFilepool.getFileStateByUrl(this.siteId, this.urlParams.url); this.canDownload$.next(true); this.state = state; diff --git a/src/core/features/login/components/site-help/site-help.html b/src/core/features/login/components/site-help/site-help.html index 10242b5cd..502818a75 100644 --- a/src/core/features/login/components/site-help/site-help.html +++ b/src/core/features/login/components/site-help/site-help.html @@ -14,7 +14,7 @@ -

{{ 'core.login.faqcannotfindmysitequestion' | translate }}

+

{{ 'core.login.faqcannotfindmysitequestion' | translate }}

@@ -24,7 +24,7 @@ -

{{ 'core.login.faqwhatisurlquestion' | translate }}

+

{{ 'core.login.faqwhatisurlquestion' | translate }}

-

{{ 'core.login.faqcannotconnectquestion' | translate }}

+

{{ 'core.login.faqcannotconnectquestion' | translate }}

@@ -44,7 +44,7 @@ -

{{ 'core.login.faqsetupsitequestion' | translate }}

+

{{ 'core.login.faqsetupsitequestion' | translate }}

@@ -57,7 +57,7 @@ -

{{ 'core.login.faqtestappquestion' | translate }}

+

{{ 'core.login.faqtestappquestion' | translate }}

@@ -67,7 +67,7 @@ -

{{ 'core.login.faqwhereisqrcode' | translate }}

+

{{ 'core.login.faqwhereisqrcode' | translate }}