diff --git a/gulp/git.js b/gulp/git.js index f3f66298a..e7eacb000 100644 --- a/gulp/git.js +++ b/gulp/git.js @@ -33,7 +33,7 @@ class Git { return new Promise((resolve, reject) => { exec(`git format-patch ${range} --stdout`, (err, result) => { if (err) { - reject(err || 'Cannot create patch.'); + reject(err); return; } diff --git a/gulp/jira.js b/gulp/jira.js index 90aeaa1c7..5e3474973 100644 --- a/gulp/jira.js +++ b/gulp/jira.js @@ -170,11 +170,11 @@ class Jira { return data; } catch (error) { // MDK not available or not configured. Ask for the data. - const data = await this.askTrackerData(); + const trackerData = await this.askTrackerData(); - data.fromInput = true; + trackerData.fromInput = true; - return data; + return trackerData; } } @@ -208,14 +208,14 @@ class Jira { return; } - exec('mdk config show tracker.username', (err, username) => { + exec('mdk config show tracker.username', (error, username) => { if (username) { resolve({ url: url.replace('\n', ''), username: username.replace('\n', ''), }); } else { - reject(err | 'Username not found.'); + reject(error || 'Username not found.'); } }); }); @@ -234,7 +234,7 @@ class Jira { } // Get tracker URL and username. - const trackerData = await this.getTrackerData(); + let trackerData = await this.getTrackerData(); this.url = trackerData.url; this.username = trackerData.username; @@ -316,15 +316,15 @@ class Jira { auth: `${this.username}:${this.password}`, headers: headers, }; - const request = https.request(url, options); + const buildRequest = https.request(url, options); // Add data. if (data) { - request.write(data); + buildRequest.write(data); } // Treat response. - request.on('response', (response) => { + buildRequest.on('response', (response) => { // Read the result. let result = ''; response.on('data', (chunk) => { @@ -344,24 +344,24 @@ class Jira { }); }); - request.on('error', (e) => { + buildRequest.on('error', (e) => { reject(e); }); // Send the request. - request.end(); + buildRequest.end(); }); } /** * Sets a set of fields for a certain issue in Jira. * - * @param key Key to identify the issue. E.g. MOBILE-1234. + * @param issueId Key to identify the issue. E.g. MOBILE-1234. * @param updates Object with the fields to update. * @return Promise resolved when done. */ - async setCustomFields(key, updates) { - const issue = await this.getIssue(key); + async setCustomFields(issueId, updates) { + const issue = await this.getIssue(issueId); const update = {'fields': {}}; // Detect which fields have changed. @@ -372,9 +372,10 @@ class Jira { if (!remoteValue || remoteValue != updateValue) { // Map the label of the field with the field code. let fieldKey; - for (const key in issue.names) { - if (issue.names[key] == updateName) { - fieldKey = key; + + for (const id in issue.names) { + if (issue.names[id] == updateName) { + fieldKey = id; break; } } @@ -439,7 +440,7 @@ class Jira { headers = headers || {}; headers['Content-Type'] = 'multipart/form-data'; - return new Promise((resolve, reject) => { + return new Promise((resolve) => { // Add the file to the form data. const formData = {}; formData[fieldName] = { @@ -462,7 +463,7 @@ class Jira { formData: formData, }; - request(options, (err, httpResponse, body) => { + request(options, (_err, httpResponse, body) => { resolve({ status: httpResponse.statusCode, data: body, diff --git a/gulp/task-build-lang.js b/gulp/task-build-lang.js index 7fe60ad7c..a8d6348cf 100644 --- a/gulp/task-build-lang.js +++ b/gulp/task-build-lang.js @@ -144,11 +144,10 @@ class BuildLangTask { switch (folders[0]) { case 'core': - switch (folders[1]) { - case 'features': - return `core.${folders[2]}.`; - default: - return 'core.'; + if (folders[1] == 'features') { + return `core.${folders[2]}.`; + } else { + return 'core.'; } case 'addons': return `addon.${folders.slice(1).join('_')}.`; diff --git a/gulp/utils.js b/gulp/utils.js index 0ca11fa74..1e8783337 100644 --- a/gulp/utils.js +++ b/gulp/utils.js @@ -58,22 +58,23 @@ class Utils { */ static getCommandLineArguments() { - let args = {}, opt, thisOpt, curOpt; - for (let a = 0; a < process.argv.length; a++) { + let args = {}; + let curOpt; - thisOpt = process.argv[a].trim(); - opt = thisOpt.replace(/^\-+/, ''); + for (const argument of process.argv) { + const thisOpt = argument.trim(); + const option = thisOpt.replace(/^\-+/, ''); - if (opt === thisOpt) { + if (option === thisOpt) { // argument value if (curOpt) { - args[curOpt] = opt; + args[curOpt] = option; } curOpt = null; } else { // Argument name. - curOpt = opt; + curOpt = option; args[curOpt] = true; } } diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index 62ba7f6a3..f2a8cde66 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -283,7 +283,7 @@ class behat_app extends behat_app_helper { // Wait until the main page appears. $this->spin( - function($context, $args) { + function($context) { $initialpage = $context->getSession()->getPage()->find('xpath', '//page-core-mainmenu') ?? $context->getSession()->getPage()->find('xpath', '//page-core-login-change-password') ?? $context->getSession()->getPage()->find('xpath', '//page-core-user-complete-profile'); @@ -780,7 +780,7 @@ class behat_app extends behat_app_helper { if (!is_null($urlpattern)) { $this->getSession()->switchToWindow($windowNames[1]); $windowurl = $this->getSession()->getCurrentUrl(); - $windowhaspattern = !!preg_match("/$urlpattern/", $windowurl); + $windowhaspattern = (bool)preg_match("/$urlpattern/", $windowurl); $this->getSession()->switchToWindow($windowNames[0]); if ($not === $windowhaspattern) { @@ -885,6 +885,8 @@ class behat_app extends behat_app_helper { case 'offline': $this->runtime_js("network.setForceConnectionMode('none');"); break; + default: + break; } } diff --git a/local_moodleappbehat/tests/behat/behat_app_helper.php b/local_moodleappbehat/tests/behat/behat_app_helper.php index 3142ce5f9..1c440ec05 100644 --- a/local_moodleappbehat/tests/behat/behat_app_helper.php +++ b/local_moodleappbehat/tests/behat/behat_app_helper.php @@ -412,12 +412,9 @@ class behat_app_helper extends behat_base { preg_match_all("/\\$\\{([^:}]+):([^}]+)\\}/", $text, $matches); foreach ($matches[0] as $index => $match) { - switch ($matches[2][$index]) { - case 'cmid': - $coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]); - $text = str_replace($match, $coursemodule->id, $text); - - break; + if ($matches[2][$index] == 'cmid') { + $coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]); + $text = str_replace($match, $coursemodule->id, $text); } } @@ -550,7 +547,7 @@ class behat_app_helper extends behat_base { if (!empty($successXPath)) { // Wait until the page appears. $this->spin( - function($context, $args) use ($successXPath) { + function($context) use ($successXPath) { $found = $context->getSession()->getPage()->find('xpath', $successXPath); if ($found) { return true; @@ -597,7 +594,6 @@ class behat_app_helper extends behat_base { $cmfrom = $cmtable->get_from_sql(); $acttable = new \core\dml\table($activity, 'a', 'a'); - $actselect = $acttable->get_field_select(); $actfrom = $acttable->get_from_sql(); $sql = <<longTasks as $longTask) { - $blocking += $longTask['duration'] - 50; + $blockingDuration += $longTask['duration'] - 50; } - $this->blocking = $blocking; + $this->blocking = $blockingDuration; } /** @@ -269,15 +269,15 @@ class performance_measure implements behat_app_listener { private function analysePerformanceLogs(): void { global $CFG; - $scripting = 0; - $styling = 0; - $networking = 0; + $scriptingDuration = 0; + $stylingDuration = 0; + $networkingCount = 0; $logs = $this->getPerformanceLogs(); foreach ($logs as $log) { // TODO this should filter by end time as well, but it seems like the timestamps are not // working as expected. - if (($log['timestamp'] < $this->start)) { + if ($log['timestamp'] < $this->start) { continue; } @@ -285,27 +285,27 @@ class performance_measure implements behat_app_listener { $messagename = $message->params->name ?? ''; if (in_array($messagename, ['FunctionCall', 'GCEvent', 'MajorGC', 'MinorGC', 'EvaluateScript'])) { - $scripting += $message->params->dur; + $scriptingDuration += $message->params->dur; continue; } if (in_array($messagename, ['UpdateLayoutTree', 'RecalculateStyles', 'ParseAuthorStyleSheet'])) { - $styling += $message->params->dur; + $stylingDuration += $message->params->dur; continue; } if (in_array($messagename, ['XHRLoad']) && !str_starts_with($message->params->args->data->url, $CFG->behat_ionic_wwwroot)) { - $networking++; + $networkingCount++; continue; } } - $this->scripting = round($scripting / 1000); - $this->styling = round($styling / 1000); - $this->networking = $networking; + $this->scripting = round($scriptingDuration / 1000); + $this->styling = round($stylingDuration / 1000); + $this->networking = $networkingCount; } /** diff --git a/scripts/build-behat-plugin.js b/scripts/build-behat-plugin.js index e5a7aebfb..9dc94bcc8 100755 --- a/scripts/build-behat-plugin.js +++ b/scripts/build-behat-plugin.js @@ -93,7 +93,7 @@ async function main() { } const newPath = featurePath.substring(0, featurePath.length - ('/tests/behat'.length)); - const searchRegExp = new RegExp('/', 'g'); + const searchRegExp = /\//g; const prefix = relative(behatTempFeaturesPath, newPath).replace(searchRegExp,'-') || 'core'; const featureFilename = prefix + '-' + basename(featureFile); renameSync(featureFile, behatFeaturesPath + '/' + featureFilename); diff --git a/scripts/get_ws_changes.php b/scripts/get_ws_changes.php index e7ee5ecff..4e5794d81 100644 --- a/scripts/get_ws_changes.php +++ b/scripts/get_ws_changes.php @@ -42,7 +42,7 @@ $versions = array('master', '310', '39', '38', '37', '36', '35', '34', '33', '32 $moodlespath = $argv[1]; $wsname = $argv[2]; -$useparams = !!(isset($argv[3]) && $argv[3]); +$useparams = (bool)(isset($argv[3]) && $argv[3]); $pathseparator = '/'; // Get the path to the script. diff --git a/scripts/get_ws_structure.php b/scripts/get_ws_structure.php index 89d5cac92..961708cc5 100644 --- a/scripts/get_ws_structure.php +++ b/scripts/get_ws_structure.php @@ -39,7 +39,7 @@ if (!defined('SERIALIZED')) { $moodlepath = $argv[1]; $wsname = $argv[2]; -$useparams = !!(isset($argv[3]) && $argv[3]); +$useparams = (bool)(isset($argv[3]) && $argv[3]); define('CLI_SCRIPT', true); diff --git a/scripts/lang_functions.php b/scripts/lang_functions.php index 9fdc5c0b9..7d2dd3990 100644 --- a/scripts/lang_functions.php +++ b/scripts/lang_functions.php @@ -302,7 +302,7 @@ function build_lang($lang) { $text = str_replace(['{{{', '}}}'], ['{{', '}}'], $text); } else { // @TODO: Remove that line when core.cannotconnect and core.login.invalidmoodleversion are completelly changed to use $a - if (($appkey == 'core.cannotconnect' || $appkey == 'core.login.invalidmoodleversion') && strpos($text, '2.4') != false) { + if (($appkey == 'core.cannotconnect' || $appkey == 'core.login.invalidmoodleversion') && strpos($text, '2.4')) { $text = str_replace('2.4', '{{$a}}', $text); } $local++; @@ -471,13 +471,10 @@ function override_component_lang_files($translations) { } switch($type) { case 'core': - switch($component) { - case 'moodle': - $path .= 'core/lang.json'; - break; - default: - $path .= 'core/features/'.str_replace('_', '/', $component).'/lang.json'; - break; + if ($component == 'moodle') { + $path .= 'core/lang.json'; + } else { + $path .= 'core/features/'.str_replace('_', '/', $component).'/lang.json'; } break; case 'addon': diff --git a/scripts/ws_to_ts_functions.php b/scripts/ws_to_ts_functions.php index 228a89649..23db31a5e 100644 --- a/scripts/ws_to_ts_functions.php +++ b/scripts/ws_to_ts_functions.php @@ -70,7 +70,7 @@ function fix_comment($desc) { if (count($lines) > 1) { $desc = array_shift($lines)."\n"; - foreach ($lines as $i => $line) { + foreach ($lines as $line) { $spaces = strlen($line) - strlen(ltrim($line)); $desc .= str_repeat(' ', $spaces - 3) . '// '. ltrim($line)."\n"; } @@ -138,9 +138,7 @@ function convert_to_ts($key, $value, $boolisnumber = false, $indentation = '', $ $type = 'number'; } - $result = convert_key_type($key, $type, $value->required, $indentation); - - return $result; + return convert_key_type($key, $type, $value->required, $indentation); } else if ($value instanceof external_single_structure) { // It's an object. @@ -278,7 +276,7 @@ function remove_default_closures($value) { } else if ($value instanceof external_single_structure) { - foreach ($value->keys as $key => $subvalue) { + foreach ($value->keys as $subvalue) { remove_default_closures($subvalue); } diff --git a/src/addons/block/myoverview/components/myoverview/myoverview.ts b/src/addons/block/myoverview/components/myoverview/myoverview.ts index 3819990c7..9bdbffe47 100644 --- a/src/addons/block/myoverview/components/myoverview/myoverview.ts +++ b/src/addons/block/myoverview/components/myoverview/myoverview.ts @@ -369,14 +369,14 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem protected async refreshCourseList(data: CoreCoursesMyCoursesUpdatedEventData): Promise { if (data.action == CoreCoursesProvider.ACTION_ENROL) { // Always update if user enrolled in a course. - return await this.refreshContent(); + return this.refreshContent(); } const course = this.allCourses.find((course) => course.id == data.courseId); if (data.action == CoreCoursesProvider.ACTION_STATE_CHANGED) { if (!course) { // Not found, use WS update. - return await this.refreshContent(); + return this.refreshContent(); } if (data.state == CoreCoursesProvider.STATE_FAVOURITE) { @@ -394,7 +394,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem if (data.action == CoreCoursesProvider.ACTION_VIEW && data.courseId != CoreSites.getCurrentSiteHomeId()) { if (!course) { // Not found, use WS update. - return await this.refreshContent(); + return this.refreshContent(); } course.lastaccess = CoreTimeUtils.timestamp(); diff --git a/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts b/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts index 31fe70756..de139997d 100644 --- a/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts +++ b/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/recentlyaccessedcourses.ts @@ -171,7 +171,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom protected async refreshCourseList(data: CoreCoursesMyCoursesUpdatedEventData): Promise { if (data.action == CoreCoursesProvider.ACTION_ENROL) { // Always update if user enrolled in a course. - return await this.refreshContent(); + return this.refreshContent(); } const courseIndex = this.courses.findIndex((course) => course.id == data.courseId); @@ -179,7 +179,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom if (data.action == CoreCoursesProvider.ACTION_VIEW && data.courseId != CoreSites.getCurrentSiteHomeId()) { if (!course) { // Not found, use WS update. - return await this.refreshContent(); + return this.refreshContent(); } // Place at the begining. diff --git a/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts b/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts index 9d3c0cd15..be5dfee71 100644 --- a/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts +++ b/src/addons/block/starredcourses/components/starredcourses/starredcourses.ts @@ -159,14 +159,14 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im if (data.action == CoreCoursesProvider.ACTION_ENROL) { // Always update if user enrolled in a course. // New courses shouldn't be favourite by default, but just in case. - return await this.refreshContent(); + return this.refreshContent(); } if (data.action == CoreCoursesProvider.ACTION_STATE_CHANGED && data.state == CoreCoursesProvider.STATE_FAVOURITE) { const courseIndex = this.courses.findIndex((course) => course.id == data.courseId); if (courseIndex < 0) { // Not found, use WS update. Usually new favourite. - return await this.refreshContent(); + return this.refreshContent(); } const course = this.courses[courseIndex]; diff --git a/src/addons/block/starredcourses/services/starredcourses.ts b/src/addons/block/starredcourses/services/starredcourses.ts index 839b05dd5..b64c20ace 100644 --- a/src/addons/block/starredcourses/services/starredcourses.ts +++ b/src/addons/block/starredcourses/services/starredcourses.ts @@ -47,7 +47,7 @@ export class AddonBlockStarredCoursesProvider { cacheKey: this.getStarredCoursesCacheKey(), }; - return await site.read('block_starredcourses_get_starred_courses', undefined, preSets); + return site.read('block_starredcourses_get_starred_courses', undefined, preSets); } /** diff --git a/src/addons/calendar/services/calendar-offline.ts b/src/addons/calendar/services/calendar-offline.ts index 5d11344fa..1eeaea9b5 100644 --- a/src/addons/calendar/services/calendar-offline.ts +++ b/src/addons/calendar/services/calendar-offline.ts @@ -74,7 +74,7 @@ export class AddonCalendarOfflineProvider { async getAllDeletedEvents(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(DELETED_EVENTS_TABLE); + return site.getDb().getRecords(DELETED_EVENTS_TABLE); } /** @@ -98,7 +98,7 @@ export class AddonCalendarOfflineProvider { async getAllEditedEvents(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(EVENTS_TABLE); + return site.getDb().getRecords(EVENTS_TABLE); } /** @@ -126,7 +126,7 @@ export class AddonCalendarOfflineProvider { id: eventId, }; - return await site.getDb().getRecord(DELETED_EVENTS_TABLE, conditions); + return site.getDb().getRecord(DELETED_EVENTS_TABLE, conditions); } /** @@ -142,7 +142,7 @@ export class AddonCalendarOfflineProvider { id: eventId, }; - return await site.getDb().getRecord(EVENTS_TABLE, conditions); + return site.getDb().getRecord(EVENTS_TABLE, conditions); } /** @@ -209,7 +209,7 @@ export class AddonCalendarOfflineProvider { timemodified: Date.now(), }; - return await site.getDb().insertRecord(DELETED_EVENTS_TABLE, event); + return site.getDb().insertRecord(DELETED_EVENTS_TABLE, event); } /** diff --git a/src/addons/calendar/services/calendar.ts b/src/addons/calendar/services/calendar.ts index 5e0f7e811..f500eb1e6 100644 --- a/src/addons/calendar/services/calendar.ts +++ b/src/addons/calendar/services/calendar.ts @@ -503,7 +503,7 @@ export class AddonCalendarProvider { async getAllEventsFromLocalDb(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getAllRecords(EVENTS_TABLE); + return site.getDb().getAllRecords(EVENTS_TABLE); } /** @@ -916,7 +916,7 @@ export class AddonCalendarProvider { async getEventReminders(id: number, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(REMINDERS_TABLE, { eventid: id }, 'timecreated ASC, time ASC'); + return site.getDb().getRecords(REMINDERS_TABLE, { eventid: id }, 'timecreated ASC, time ASC'); } /** @@ -1021,7 +1021,7 @@ export class AddonCalendarProvider { async getLocalEventsByRepeatIdFromLocalDb(repeatId: number, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(EVENTS_TABLE, { repeatid: repeatId }); + return site.getDb().getRecords(EVENTS_TABLE, { repeatid: repeatId }); } /** diff --git a/src/addons/coursecompletion/services/handlers/user.ts b/src/addons/coursecompletion/services/handlers/user.ts index bfd75dfaa..28bece14e 100644 --- a/src/addons/coursecompletion/services/handlers/user.ts +++ b/src/addons/coursecompletion/services/handlers/user.ts @@ -57,7 +57,7 @@ export class AddonCourseCompletionUserHandlerService implements CoreUserProfileH * @inheritdoc */ async isEnabledForUser(user: CoreUserProfile, context: CoreUserDelegateContext, contextId: number): Promise { - return await AddonCourseCompletion.isPluginViewEnabledForUser(contextId, user.id); + return AddonCourseCompletion.isPluginViewEnabledForUser(contextId, user.id); } /** diff --git a/src/addons/messages/services/handlers/settings.ts b/src/addons/messages/services/handlers/settings.ts index 9f5662d61..00b0eef21 100644 --- a/src/addons/messages/services/handlers/settings.ts +++ b/src/addons/messages/services/handlers/settings.ts @@ -34,7 +34,7 @@ export class AddonMessagesSettingsHandlerService implements CoreSettingsHandler * @return Whether or not the handler is enabled on a site level. */ async isEnabled(): Promise { - return await AddonMessages.isPluginEnabled(); + return AddonMessages.isPluginEnabled(); } /** diff --git a/src/addons/messages/services/messages.ts b/src/addons/messages/services/messages.ts index ca7e16d4f..c72ad0609 100644 --- a/src/addons/messages/services/messages.ts +++ b/src/addons/messages/services/messages.ts @@ -1620,13 +1620,12 @@ export class AddonMessagesProvider { preSets.emergencyCache = false; } - return await this.getMessages(params, preSets, siteId); + return this.getMessages(params, preSets, siteId); } /** * Invalidate all contacts cache. * - * @param userId The user ID. * @param siteId Site ID. If not defined, current site. * @return Resolved when done. */ @@ -2517,7 +2516,7 @@ export class AddonMessagesProvider { messages, }; - return await site.write('core_message_send_instant_messages', data); + return site.write('core_message_send_instant_messages', data); } /** @@ -2651,7 +2650,7 @@ export class AddonMessagesProvider { })), }; - return await site.write('core_message_send_messages_to_conversation', params); + return site.write('core_message_send_messages_to_conversation', params); } /** diff --git a/src/addons/mod/assign/components/index/index.ts b/src/addons/mod/assign/components/index/index.ts index 37998df5b..a29597a92 100644 --- a/src/addons/mod/assign/components/index/index.ts +++ b/src/addons/mod/assign/components/index/index.ts @@ -389,7 +389,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo return; } - return await AddonModAssignSync.syncAssign(this.assign.id); + return AddonModAssignSync.syncAssign(this.assign.id); } /** diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index 8cc7d519a..4233d4137 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -329,7 +329,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { // Cannot submit in online, prepare for offline usage. this.saveOffline = true; - return await AddonModAssignHelper.prepareSubmissionPluginData( + return AddonModAssignHelper.prepareSubmissionPluginData( this.assign!, this.userSubmission, inputData, diff --git a/src/addons/mod/assign/services/assign-offline.ts b/src/addons/mod/assign/services/assign-offline.ts index d57ce3d2e..954c68b0f 100644 --- a/src/addons/mod/assign/services/assign-offline.ts +++ b/src/addons/mod/assign/services/assign-offline.ts @@ -353,7 +353,7 @@ export class AddonModAssignOfflineProvider { }; } - return await site.getDb().insertRecord(SUBMISSIONS_TABLE, submission); + return site.getDb().insertRecord(SUBMISSIONS_TABLE, submission); } /** @@ -393,7 +393,7 @@ export class AddonModAssignOfflineProvider { onlinetimemodified: timemodified, }; - return await site.getDb().insertRecord(SUBMISSIONS_TABLE, entry); + return site.getDb().insertRecord(SUBMISSIONS_TABLE, entry); } /** @@ -442,7 +442,7 @@ export class AddonModAssignOfflineProvider { timemodified: now, }; - return await site.getDb().insertRecord(SUBMISSIONS_GRADES_TABLE, entry); + return site.getDb().insertRecord(SUBMISSIONS_GRADES_TABLE, entry); } } diff --git a/src/addons/mod/assign/services/feedback-delegate.ts b/src/addons/mod/assign/services/feedback-delegate.ts index 21dd7eafa..253b7c53d 100644 --- a/src/addons/mod/assign/services/feedback-delegate.ts +++ b/src/addons/mod/assign/services/feedback-delegate.ts @@ -203,7 +203,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(plugin.type, 'discardDraft', [assignId, userId, siteId]); + return this.executeFunctionOnEnabled(plugin.type, 'discardDraft', [assignId, userId, siteId]); } /** @@ -215,7 +215,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate | undefined> { - return await this.executeFunctionOnEnabled(plugin.type, 'getComponent', [plugin]); + return this.executeFunctionOnEnabled(plugin.type, 'getComponent', [plugin]); } /** @@ -233,7 +233,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(plugin.type, 'getDraft', [assignId, userId, siteId]); + return this.executeFunctionOnEnabled(plugin.type, 'getDraft', [assignId, userId, siteId]); } /** @@ -285,7 +285,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'hasDataChanged', [assign, submission, plugin, inputData, userId], @@ -307,7 +307,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(plugin.type, 'hasDraftData', [assignId, userId, siteId]); + return this.executeFunctionOnEnabled(plugin.type, 'hasDraftData', [assignId, userId, siteId]); } /** @@ -335,7 +335,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(plugin.type, 'prefetch', [assign, submission, plugin, siteId]); + return this.executeFunctionOnEnabled(plugin.type, 'prefetch', [assign, submission, plugin, siteId]); } /** @@ -356,7 +356,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'prepareFeedbackData', [assignId, userId, plugin, pluginData, siteId], @@ -380,7 +380,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'saveDraft', [assignId, userId, plugin, inputData, siteId], diff --git a/src/addons/mod/assign/services/submission-delegate.ts b/src/addons/mod/assign/services/submission-delegate.ts index 73dfd082a..f313f5ffc 100644 --- a/src/addons/mod/assign/services/submission-delegate.ts +++ b/src/addons/mod/assign/services/submission-delegate.ts @@ -293,7 +293,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(plugin.type, 'canEditOffline', [assign, submission, plugin]); + return this.executeFunctionOnEnabled(plugin.type, 'canEditOffline', [assign, submission, plugin]); } /** @@ -330,7 +330,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'copySubmissionData', [assign, plugin, pluginData, userId, siteId], @@ -354,7 +354,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'deleteOfflineData', [assign, submission, plugin, offlineData, siteId], @@ -372,7 +372,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate | undefined> { - return await this.executeFunctionOnEnabled(plugin.type, 'getComponent', [plugin, edit]); + return this.executeFunctionOnEnabled(plugin.type, 'getComponent', [plugin, edit]); } /** @@ -415,7 +415,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(plugin.type, 'getSizeForCopy', [assign, plugin]); + return this.executeFunctionOnEnabled(plugin.type, 'getSizeForCopy', [assign, plugin]); } /** @@ -433,7 +433,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'getSizeForEdit', [assign, submission, plugin, inputData], @@ -455,7 +455,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'hasDataChanged', [assign, submission, plugin, inputData], @@ -479,7 +479,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(pluginType, 'isEnabledForEdit'); + return this.executeFunctionOnEnabled(pluginType, 'isEnabledForEdit'); } /** @@ -508,7 +508,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(plugin.type, 'prefetch', [assign, submission, plugin, siteId]); + return this.executeFunctionOnEnabled(plugin.type, 'prefetch', [assign, submission, plugin, siteId]); } /** @@ -535,7 +535,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( plugin.type, 'prepareSubmissionData', [assign, submission, plugin, inputData, pluginData, offline, userId, siteId], diff --git a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts index 4889b310d..fb64603ee 100644 --- a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts +++ b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts @@ -166,7 +166,7 @@ export class AddonModBBBService { ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; - return await site.read( + return site.read( 'mod_bigbluebuttonbn_meeting_info', params, preSets, diff --git a/src/addons/mod/data/components/index/index.ts b/src/addons/mod/data/components/index/index.ts index 07a9190d3..024260da0 100644 --- a/src/addons/mod/data/components/index/index.ts +++ b/src/addons/mod/data/components/index/index.ts @@ -103,7 +103,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp num: number; max: number; reseturl: string; - };; + }; hasOfflineRatings = false; diff --git a/src/addons/mod/feedback/services/feedback-helper.ts b/src/addons/mod/feedback/services/feedback-helper.ts index 18a9a50f3..0403f4556 100644 --- a/src/addons/mod/feedback/services/feedback-helper.ts +++ b/src/addons/mod/feedback/services/feedback-helper.ts @@ -225,7 +225,7 @@ export class AddonModFeedbackHelperProvider { protected async addImageProfile( entries: (AddonModFeedbackWSAttempt | AddonModFeedbackWSNonRespondent)[], ): Promise<(AddonModFeedbackAttempt | AddonModFeedbackNonRespondent)[]> { - return await Promise.all(entries.map(async (entry: AddonModFeedbackAttempt | AddonModFeedbackNonRespondent) => { + return Promise.all(entries.map(async (entry: AddonModFeedbackAttempt | AddonModFeedbackNonRespondent) => { try { const user = await CoreUser.getProfile(entry.userid, entry.courseid, true); diff --git a/src/addons/mod/forum/services/forum-sync.ts b/src/addons/mod/forum/services/forum-sync.ts index f08542f5b..7b943afc5 100644 --- a/src/addons/mod/forum/services/forum-sync.ts +++ b/src/addons/mod/forum/services/forum-sync.ts @@ -126,6 +126,8 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide return; } + syncedDiscussionIds.push(reply.discussionid); + const result = force ? await this.syncDiscussionReplies(reply.discussionid, reply.userid, siteId) : await this.syncDiscussionRepliesIfNeeded(reply.discussionid, reply.userid, siteId); diff --git a/src/addons/mod/forum/services/handlers/prefetch.ts b/src/addons/mod/forum/services/handlers/prefetch.ts index 6574fb239..fa9c27762 100644 --- a/src/addons/mod/forum/services/handlers/prefetch.ts +++ b/src/addons/mod/forum/services/handlers/prefetch.ts @@ -119,7 +119,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe throw new Error('Failed getting discussions'); } - return await Promise.all( + return Promise.all( response.discussions.map((discussion) => AddonModForum.getDiscussionPosts(discussion.discussion, options)), ); })); diff --git a/src/addons/mod/glossary/services/glossary.ts b/src/addons/mod/glossary/services/glossary.ts index 53ef5b21f..4b31042e5 100644 --- a/src/addons/mod/glossary/services/glossary.ts +++ b/src/addons/mod/glossary/services/glossary.ts @@ -673,7 +673,7 @@ export class AddonModGlossaryProvider { * @return Promise resolved with all entrries. */ fetchAllEntries( - fetchFunction: (options?: AddonModGlossaryGetEntriesOptions) => AddonModGlossaryGetEntriesWSResponse, + fetchFunction: (options?: AddonModGlossaryGetEntriesOptions) => Promise, options: CoreCourseCommonModWSOptions = {}, ): Promise { options.siteId = options.siteId || CoreSites.getCurrentSiteId(); @@ -681,7 +681,7 @@ export class AddonModGlossaryProvider { const entries: AddonModGlossaryEntry[] = []; const fetchMoreEntries = async (): Promise => { - const result = fetchFunction({ + const result = await fetchFunction({ from: entries.length, ...options, // Include all options. }); diff --git a/src/addons/mod/h5pactivity/components/index/index.ts b/src/addons/mod/h5pactivity/components/index/index.ts index 74e0277b2..be5b42515 100644 --- a/src/addons/mod/h5pactivity/components/index/index.ts +++ b/src/addons/mod/h5pactivity/components/index/index.ts @@ -518,7 +518,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv }; } - return await AddonModH5PActivitySync.syncActivity(this.h5pActivity.context, this.site.getId()); + return AddonModH5PActivitySync.syncActivity(this.h5pActivity.context, this.site.getId()); } /** diff --git a/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts b/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts index f50cd056c..d77dca7a2 100644 --- a/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts +++ b/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts @@ -143,7 +143,7 @@ export class AddonModH5PActivityUsersAttemptsPage implements OnInit { h5pActivity: AddonModH5PActivityData, users: AddonModH5PActivityUserAttempts[], ): Promise { - return await Promise.all(users.map(async (user: AddonModH5PActivityUserAttemptsFormatted) => { + return Promise.all(users.map(async (user: AddonModH5PActivityUserAttemptsFormatted) => { user.user = await CoreUser.getProfile(user.userid, this.courseId, true); // Calculate the score of the user. diff --git a/src/addons/mod/survey/components/index/index.ts b/src/addons/mod/survey/components/index/index.ts index 73999cf7a..d69ea2140 100644 --- a/src/addons/mod/survey/components/index/index.ts +++ b/src/addons/mod/survey/components/index/index.ts @@ -214,7 +214,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo // Update the view. prefetched ? this.showLoadingAndFetch(false, false) : - this.showLoadingAndRefresh(false);; + this.showLoadingAndRefresh(false); } catch { // Prefetch failed, refresh the data. this.showLoadingAndRefresh(false); diff --git a/src/addons/notes/services/notes-offline.ts b/src/addons/notes/services/notes-offline.ts index e4a790d60..4666e07c9 100644 --- a/src/addons/notes/services/notes-offline.ts +++ b/src/addons/notes/services/notes-offline.ts @@ -115,7 +115,7 @@ export class AddonNotesOfflineProvider { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(NOTES_TABLE, { userid: userId, courseid: courseId }); + return site.getDb().getRecords(NOTES_TABLE, { userid: userId, courseid: courseId }); } /** @@ -141,7 +141,7 @@ export class AddonNotesOfflineProvider { async getNotesForUser(userId: number, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(NOTES_TABLE, { userid: userId }); + return site.getDb().getRecords(NOTES_TABLE, { userid: userId }); } /** @@ -154,7 +154,7 @@ export class AddonNotesOfflineProvider { async getNotesWithPublishState(state: AddonNotesPublishState, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(NOTES_TABLE, { publishstate: state }); + return site.getDb().getRecords(NOTES_TABLE, { publishstate: state }); } /** diff --git a/src/addons/notes/services/notes.ts b/src/addons/notes/services/notes.ts index 3b992e6cc..0e3578aa1 100644 --- a/src/addons/notes/services/notes.ts +++ b/src/addons/notes/services/notes.ts @@ -177,7 +177,7 @@ export class AddonNotesProvider { throw error; } - return await storeOffline(); + return storeOffline(); } } diff --git a/src/addons/remotethemes/services/remotethemes-handler.ts b/src/addons/remotethemes/services/remotethemes-handler.ts index 2d553046f..6fea80158 100644 --- a/src/addons/remotethemes/services/remotethemes-handler.ts +++ b/src/addons/remotethemes/services/remotethemes-handler.ts @@ -60,7 +60,7 @@ export class AddonRemoteThemesHandlerService implements CoreStyleHandler { } // Config received, it's a temp site. - return await this.getRemoteStyles(config.mobilecssurl); + return this.getRemoteStyles(config.mobilecssurl); } const site = await CoreSites.getSite(siteId); @@ -108,7 +108,7 @@ export class AddonRemoteThemesHandlerService implements CoreStyleHandler { return ''; } - return await CoreWS.getText(url); + return CoreWS.getText(url); } /** diff --git a/src/addons/report/insights/services/handlers/action-link.ts b/src/addons/report/insights/services/handlers/action-link.ts index 75dfc371e..1c25b13db 100644 --- a/src/addons/report/insights/services/handlers/action-link.ts +++ b/src/addons/report/insights/services/handlers/action-link.ts @@ -96,7 +96,7 @@ export class AddonReportInsightsActionLinkHandlerService extends CoreContentLink return false; } - return await AddonReportInsights.canSendActionInSite(siteId); + return AddonReportInsights.canSendActionInSite(siteId); } } diff --git a/src/app/app.component.scss b/src/app/app.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a4f2c7c0f..9535bbc78 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -41,7 +41,6 @@ const MOODLEAPP_VERSION_PREFIX = 'moodleapp-'; @Component({ selector: 'app-root', templateUrl: 'app.component.html', - styleUrls: ['app.component.scss'], }) export class AppComponent implements OnInit, AfterViewInit { diff --git a/src/assets/js/iframe-treat-links.js b/src/assets/js/iframe-treat-links.js index abded2658..e1a507545 100644 --- a/src/assets/js/iframe-treat-links.js +++ b/src/assets/js/iframe-treat-links.js @@ -13,9 +13,9 @@ // limitations under the License. (function () { - var url = location.href; + const locationHref = location.href; - if (url.match(/^moodleappfs:\/\/localhost/i) || !url.match(/^[a-z0-9]+:\/\//i)) { + if (locationHref.match(/^moodleappfs:\/\/localhost/i) || !locationHref.match(/^[a-z0-9]+:\/\//i)) { // Same domain as the app, stop. return; } @@ -41,14 +41,14 @@ }; // Handle link clicks. - document.addEventListener('click', (event) => { - if (event.defaultPrevented) { + document.addEventListener('click', (documentClickEvent) => { + if (documentClickEvent.defaultPrevented) { // Event already prevented by some other code. return; } // Find the link being clicked. - var el = event.target; + let el = documentClickEvent.target; while (el && (el.tagName !== 'A' && el.tagName !== 'a')) { el = el.parentElement; } @@ -59,8 +59,8 @@ // Add click listener to the link, this way if the iframe has added a listener to the link it will be executed first. el.treated = true; - el.addEventListener('click', function(event) { - linkClicked(el, event); + el.addEventListener('click', function(elementClickEvent) { + linkClicked(el, elementClickEvent); }); }, { capture: true // Use capture to fix this listener not called if the element clicked is too deep in the DOM. @@ -82,8 +82,8 @@ return leftPath; } - var lastCharLeft = leftPath.slice(-1); - var firstCharRight = rightPath.charAt(0); + const lastCharLeft = leftPath.slice(-1); + const firstCharRight = rightPath.charAt(0); if (lastCharLeft === '/' && firstCharRight === '/') { return leftPath + rightPath.substr(1); @@ -119,7 +119,7 @@ return; } - var matches = url.match(/^([a-z][a-z0-9+\-.]*):/); + const matches = url.match(/^([a-z][a-z0-9+\-.]*):/); if (matches && matches[1]) { return matches[1]; } @@ -164,9 +164,9 @@ return; } - var linkScheme = getUrlScheme(link.href); - var pageScheme = getUrlScheme(location.href); - var isTargetSelf = !link.target || link.target == '_self'; + const linkScheme = getUrlScheme(link.href); + const pageScheme = getUrlScheme(location.href); + const isTargetSelf = !link.target || link.target == '_self'; if (!link.href || linkScheme == 'javascript') { // Links with no URL and Javascript links are ignored. @@ -207,7 +207,7 @@ } // It's a relative URL, use the frame src to create the full URL. - var pathToDir = location.href.substring(0, location.href.lastIndexOf('/')); + const pathToDir = location.href.substring(0, location.href.lastIndexOf('/')); return concatenatePaths(pathToDir, url); } diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 295a60a83..f265323d4 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -2134,7 +2134,7 @@ export class CoreSite { async getLastViewed(component: string, id: number): Promise { try { return await this.lastViewedTable.getOneByPrimaryKey({ component, id }); - } catch (error) { + } catch { // Not found. } } @@ -2162,7 +2162,7 @@ export class CoreSite { sqlParams: whereAndParams.params, js: (record) => record.component === component && ids.includes(record.id), }); - } catch (error) { + } catch { // Not found. } } diff --git a/src/core/classes/tabs.ts b/src/core/classes/tabs.ts index 6e741e934..c5cac4b9c 100644 --- a/src/core/classes/tabs.ts +++ b/src/core/classes/tabs.ts @@ -569,7 +569,7 @@ export class CoreTabsBaseComponent implements OnInit, Aft * @inheritdoc */ async ready(): Promise { - return await this.onReadyPromise; + return this.onReadyPromise; } /** diff --git a/src/core/features/comments/services/comments-offline.ts b/src/core/features/comments/services/comments-offline.ts index 9ab9ade8a..a5bdbc999 100644 --- a/src/core/features/comments/services/comments-offline.ts +++ b/src/core/features/comments/services/comments-offline.ts @@ -116,7 +116,7 @@ export class CoreCommentsOfflineProvider { async getAllDeletedComments(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(COMMENTS_DELETED_TABLE); + return site.getDb().getRecords(COMMENTS_DELETED_TABLE); } /** diff --git a/src/core/features/comments/services/comments.ts b/src/core/features/comments/services/comments.ts index 1b8424923..660d0593a 100644 --- a/src/core/features/comments/services/comments.ts +++ b/src/core/features/comments/services/comments.ts @@ -176,7 +176,7 @@ export class CoreCommentsProvider { comments: comments, }; - return await site.write('core_comment_add_comments', data); + return site.write('core_comment_add_comments', data); } /** diff --git a/src/core/features/contentlinks/services/contentlinks-delegate.ts b/src/core/features/contentlinks/services/contentlinks-delegate.ts index 3d5b98d15..fa8e6575e 100644 --- a/src/core/features/contentlinks/services/contentlinks-delegate.ts +++ b/src/core/features/contentlinks/services/contentlinks-delegate.ts @@ -301,7 +301,7 @@ export class CoreContentLinksDelegateService { return true; } - return await handler.isEnabled(siteId, url, params, courseId); + return handler.isEnabled(siteId, url, params, courseId); } /** diff --git a/src/core/features/course/components/module-summary/module-summary.ts b/src/core/features/course/components/module-summary/module-summary.ts index dd3c6cbb6..1b6edd6df 100644 --- a/src/core/features/course/components/module-summary/module-summary.ts +++ b/src/core/features/course/components/module-summary/module-summary.ts @@ -60,7 +60,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { removeFilesLoading = false; prefetchLoading = false; - canPrefetch = false;; + canPrefetch = false; prefetchDisabled = false; size?: number; // Size in bytes downloadTimeReadable = ''; // Last download time in a readable format. diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index 094f08205..e42f3bd71 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -1017,10 +1017,10 @@ export class CoreCourseHelperProvider { if (prefetchHandler) { // Use the prefetch handler to download the module. if (prefetchHandler.download) { - return await prefetchHandler.download(module, courseId); + return prefetchHandler.download(module, courseId); } - return await prefetchHandler.prefetch(module, courseId, true); + return prefetchHandler.prefetch(module, courseId, true); } // There's no prefetch handler for the module, just download the files. diff --git a/src/core/features/course/services/course-offline.ts b/src/core/features/course/services/course-offline.ts index 033c9f551..265d3967e 100644 --- a/src/core/features/course/services/course-offline.ts +++ b/src/core/features/course/services/course-offline.ts @@ -46,7 +46,7 @@ export class CoreCourseOfflineProvider { async getAllManualCompletions(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(MANUAL_COMPLETION_TABLE); + return site.getDb().getRecords(MANUAL_COMPLETION_TABLE); } /** @@ -59,7 +59,7 @@ export class CoreCourseOfflineProvider { async getCourseManualCompletions(courseId: number, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecords(MANUAL_COMPLETION_TABLE, { courseid: courseId }); + return site.getDb().getRecords(MANUAL_COMPLETION_TABLE, { courseid: courseId }); } /** @@ -72,7 +72,7 @@ export class CoreCourseOfflineProvider { async getManualCompletion(cmId: number, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return await site.getDb().getRecord(MANUAL_COMPLETION_TABLE, { cmid: cmId }); + return site.getDb().getRecord(MANUAL_COMPLETION_TABLE, { cmid: cmId }); } /** diff --git a/src/core/features/course/services/course-options-delegate.ts b/src/core/features/course/services/course-options-delegate.ts index 564f4965b..7c4a4a62e 100644 --- a/src/core/features/course/services/course-options-delegate.ts +++ b/src/core/features/course/services/course-options-delegate.ts @@ -484,7 +484,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate { const site = await CoreSites.getSite(siteId); - return await this.viewedModulesTables[site.getId()].getMany({ courseId }, { + return this.viewedModulesTables[site.getId()].getMany({ courseId }, { sorting: [ { timeaccess: 'desc' }, ], diff --git a/src/core/features/course/services/format-delegate.ts b/src/core/features/course/services/format-delegate.ts index 12f87c94d..34819b9ba 100644 --- a/src/core/features/course/services/format-delegate.ts +++ b/src/core/features/course/services/format-delegate.ts @@ -394,7 +394,7 @@ export class CoreCourseFormatDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled(course.format || '', 'shouldRefreshWhenCompletionChanges', [course]); + return this.executeFunctionOnEnabled(course.format || '', 'shouldRefreshWhenCompletionChanges', [course]); } } diff --git a/src/core/features/course/services/module-delegate.ts b/src/core/features/course/services/module-delegate.ts index 89bcd8ec7..76680e2f5 100644 --- a/src/core/features/course/services/module-delegate.ts +++ b/src/core/features/course/services/module-delegate.ts @@ -326,7 +326,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate { - return await this.executeFunctionOnEnabled( + return this.executeFunctionOnEnabled( modname, 'openActivityPage', [module, courseId, options], diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index 96ebcd9f9..944a887d6 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -103,7 +103,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate('core_course_get_recent_courses', params, preSets); + return site.read('core_course_get_recent_courses', params, preSets); } /** @@ -720,7 +720,6 @@ export class CoreCoursesProvider { /** * Get the common part of the cache keys for user navigation options WS calls. * - * @param courseIds IDs of courses to get. * @return Cache key. */ protected getUserNavigationOptionsCommonCacheKey(): string { diff --git a/src/core/features/courses/services/dashboard.ts b/src/core/features/courses/services/dashboard.ts index 8a5eb2d84..6e687c0e1 100644 --- a/src/core/features/courses/services/dashboard.ts +++ b/src/core/features/courses/services/dashboard.ts @@ -145,7 +145,7 @@ export class CoreCoursesDashboardProvider { ): Promise { const site = await CoreSites.getSite(siteId); - return await site.invalidateWsCacheForKey(this.getDashboardBlocksCacheKey(myPage, userId)); + return site.invalidateWsCacheForKey(this.getDashboardBlocksCacheKey(myPage, userId)); } /** diff --git a/src/core/features/grades/pages/course/course.html b/src/core/features/grades/pages/course/course.html index de30057bd..bf4835c89 100644 --- a/src/core/features/grades/pages/course/course.html +++ b/src/core/features/grades/pages/course/course.html @@ -16,7 +16,7 @@
- +
{ + return Promise.all(table.tabledata.filter((row) => { if (row.itemname && row.itemname.content) { const matches = row.itemname.content.match(regex); diff --git a/src/core/features/grades/services/grades.ts b/src/core/features/grades/services/grades.ts index c7aa1aa7c..d6498132d 100644 --- a/src/core/features/grades/services/grades.ts +++ b/src/core/features/grades/services/grades.ts @@ -108,7 +108,7 @@ export class CoreGradesProvider { userId = userId || site.getUserId(); - return await this.getCourseGradesItems(courseId, userId, groupId, siteId, ignoreCache); + return this.getCourseGradesItems(courseId, userId, groupId, siteId, ignoreCache); } /** diff --git a/src/core/features/tag/services/tag-area-delegate.ts b/src/core/features/tag/services/tag-area-delegate.ts index e2f0e464d..5b5e7a306 100644 --- a/src/core/features/tag/services/tag-area-delegate.ts +++ b/src/core/features/tag/services/tag-area-delegate.ts @@ -75,7 +75,7 @@ export class CoreTagAreaDelegateService extends CoreDelegate async parseContent(component: string, itemType: string, content: string): Promise { const type = component + '/' + itemType; - return await this.executeFunctionOnEnabled(type, 'parseContent', [content]); + return this.executeFunctionOnEnabled(type, 'parseContent', [content]); } /** @@ -88,7 +88,7 @@ export class CoreTagAreaDelegateService extends CoreDelegate async getComponent(component: string, itemType: string): Promise | undefined> { const type = component + '/' + itemType; - return await this.executeFunctionOnEnabled(type, 'getComponent'); + return this.executeFunctionOnEnabled(type, 'getComponent'); } } diff --git a/src/core/features/user/services/user-profile-field-delegate.ts b/src/core/features/user/services/user-profile-field-delegate.ts index 6a5b2c284..caeac6817 100644 --- a/src/core/features/user/services/user-profile-field-delegate.ts +++ b/src/core/features/user/services/user-profile-field-delegate.ts @@ -139,7 +139,7 @@ export class CoreUserProfileFieldDelegateService extends CoreDelegate('current_language'); - } catch (e) { + } catch { // Try will return, ignore errors here to avoid nesting. } diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 15bce3bba..67754f37b 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -1260,7 +1260,7 @@ export class CoreSitesProvider { async getSitesInstances(): Promise { const siteIds = await this.getSitesIds(); - return await Promise.all(siteIds.map(async (siteId) => await this.getSite(siteId))); + return Promise.all(siteIds.map(async (siteId) => await this.getSite(siteId))); } /** @@ -1572,7 +1572,7 @@ export class CoreSitesProvider { * @return Promise resolved with config if available. */ protected async getSiteConfig(site: CoreSite): Promise { - return await site.getConfig(undefined, true); + return site.getConfig(undefined, true); } /** diff --git a/src/core/services/sync.ts b/src/core/services/sync.ts index c48c3a055..e25cd4a56 100644 --- a/src/core/services/sync.ts +++ b/src/core/services/sync.ts @@ -100,7 +100,7 @@ export class CoreSyncProvider { async getSyncRecord(component: string, id: string | number, siteId?: string): Promise { const db = await CoreSites.getSiteDb(siteId); - return await db.getRecord(SYNC_TABLE_NAME, { component: component, id: String(id) }); + return db.getRecord(SYNC_TABLE_NAME, { component: component, id: String(id) }); } /** diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index eb0289307..9cf705339 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -1782,7 +1782,7 @@ export class CoreDomUtilsProvider { leaveAnimation: CoreModalLateralTransitionLeave, }, options); - return await this.openModal(options); + return this.openModal(options); } /** diff --git a/src/core/services/utils/utils.ts b/src/core/services/utils/utils.ts index 58431922a..c8f588d94 100644 --- a/src/core/services/utils/utils.ts +++ b/src/core/services/utils/utils.ts @@ -689,7 +689,7 @@ export class CoreUtilsProvider { throw new Error('Countries not found.'); } - return await this.getCountryKeysListForLanguage(fallbackLang); + return this.getCountryKeysListForLanguage(fallbackLang); } } @@ -1611,7 +1611,7 @@ export class CoreUtilsProvider { * @return Promise resolved with the captured text or undefined if cancelled or error. */ async scanQR(title?: string): Promise { - return await CoreDomUtils.openModal({ + return CoreDomUtils.openModal({ component: CoreViewerQRScannerComponent, cssClass: 'core-modal-fullscreen', componentProps: { diff --git a/src/core/singletons/dom.ts b/src/core/singletons/dom.ts index 65e16c62c..357fd6264 100644 --- a/src/core/singletons/dom.ts +++ b/src/core/singletons/dom.ts @@ -175,7 +175,7 @@ export class CoreDom { slot.removeEventListener('slotchange', slotListener); }; - slot.addEventListener('slotchange', slotListener);; + slot.addEventListener('slotchange', slotListener); } /**