Merge pull request #3369 from crazyserver/MOBILE-4081

Mobile 4081
main
Dani Palou 2022-09-02 15:54:19 +02:00 committed by GitHub
commit 6c5984e263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 181 additions and 188 deletions

View File

@ -33,7 +33,7 @@ class Git {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
exec(`git format-patch ${range} --stdout`, (err, result) => { exec(`git format-patch ${range} --stdout`, (err, result) => {
if (err) { if (err) {
reject(err || 'Cannot create patch.'); reject(err);
return; return;
} }

View File

@ -170,11 +170,11 @@ class Jira {
return data; return data;
} catch (error) { } catch (error) {
// MDK not available or not configured. Ask for the data. // 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; return;
} }
exec('mdk config show tracker.username', (err, username) => { exec('mdk config show tracker.username', (error, username) => {
if (username) { if (username) {
resolve({ resolve({
url: url.replace('\n', ''), url: url.replace('\n', ''),
username: username.replace('\n', ''), username: username.replace('\n', ''),
}); });
} else { } else {
reject(err | 'Username not found.'); reject(error || 'Username not found.');
} }
}); });
}); });
@ -234,7 +234,7 @@ class Jira {
} }
// Get tracker URL and username. // Get tracker URL and username.
const trackerData = await this.getTrackerData(); let trackerData = await this.getTrackerData();
this.url = trackerData.url; this.url = trackerData.url;
this.username = trackerData.username; this.username = trackerData.username;
@ -316,15 +316,15 @@ class Jira {
auth: `${this.username}:${this.password}`, auth: `${this.username}:${this.password}`,
headers: headers, headers: headers,
}; };
const request = https.request(url, options); const buildRequest = https.request(url, options);
// Add data. // Add data.
if (data) { if (data) {
request.write(data); buildRequest.write(data);
} }
// Treat response. // Treat response.
request.on('response', (response) => { buildRequest.on('response', (response) => {
// Read the result. // Read the result.
let result = ''; let result = '';
response.on('data', (chunk) => { response.on('data', (chunk) => {
@ -344,24 +344,24 @@ class Jira {
}); });
}); });
request.on('error', (e) => { buildRequest.on('error', (e) => {
reject(e); reject(e);
}); });
// Send the request. // Send the request.
request.end(); buildRequest.end();
}); });
} }
/** /**
* Sets a set of fields for a certain issue in Jira. * 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. * @param updates Object with the fields to update.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
async setCustomFields(key, updates) { async setCustomFields(issueId, updates) {
const issue = await this.getIssue(key); const issue = await this.getIssue(issueId);
const update = {'fields': {}}; const update = {'fields': {}};
// Detect which fields have changed. // Detect which fields have changed.
@ -372,9 +372,10 @@ class Jira {
if (!remoteValue || remoteValue != updateValue) { if (!remoteValue || remoteValue != updateValue) {
// Map the label of the field with the field code. // Map the label of the field with the field code.
let fieldKey; let fieldKey;
for (const key in issue.names) {
if (issue.names[key] == updateName) { for (const id in issue.names) {
fieldKey = key; if (issue.names[id] == updateName) {
fieldKey = id;
break; break;
} }
} }
@ -439,7 +440,7 @@ class Jira {
headers = headers || {}; headers = headers || {};
headers['Content-Type'] = 'multipart/form-data'; headers['Content-Type'] = 'multipart/form-data';
return new Promise((resolve, reject) => { return new Promise((resolve) => {
// Add the file to the form data. // Add the file to the form data.
const formData = {}; const formData = {};
formData[fieldName] = { formData[fieldName] = {
@ -462,7 +463,7 @@ class Jira {
formData: formData, formData: formData,
}; };
request(options, (err, httpResponse, body) => { request(options, (_err, httpResponse, body) => {
resolve({ resolve({
status: httpResponse.statusCode, status: httpResponse.statusCode,
data: body, data: body,

View File

@ -144,11 +144,10 @@ class BuildLangTask {
switch (folders[0]) { switch (folders[0]) {
case 'core': case 'core':
switch (folders[1]) { if (folders[1] == 'features') {
case 'features': return `core.${folders[2]}.`;
return `core.${folders[2]}.`; } else {
default: return 'core.';
return 'core.';
} }
case 'addons': case 'addons':
return `addon.${folders.slice(1).join('_')}.`; return `addon.${folders.slice(1).join('_')}.`;

View File

@ -58,22 +58,23 @@ class Utils {
*/ */
static getCommandLineArguments() { static getCommandLineArguments() {
let args = {}, opt, thisOpt, curOpt; let args = {};
for (let a = 0; a < process.argv.length; a++) { let curOpt;
thisOpt = process.argv[a].trim(); for (const argument of process.argv) {
opt = thisOpt.replace(/^\-+/, ''); const thisOpt = argument.trim();
const option = thisOpt.replace(/^\-+/, '');
if (opt === thisOpt) { if (option === thisOpt) {
// argument value // argument value
if (curOpt) { if (curOpt) {
args[curOpt] = opt; args[curOpt] = option;
} }
curOpt = null; curOpt = null;
} }
else { else {
// Argument name. // Argument name.
curOpt = opt; curOpt = option;
args[curOpt] = true; args[curOpt] = true;
} }
} }

View File

@ -283,7 +283,7 @@ class behat_app extends behat_app_helper {
// Wait until the main page appears. // Wait until the main page appears.
$this->spin( $this->spin(
function($context, $args) { function($context) {
$initialpage = $context->getSession()->getPage()->find('xpath', '//page-core-mainmenu') ?? $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-login-change-password') ??
$context->getSession()->getPage()->find('xpath', '//page-core-user-complete-profile'); $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)) { if (!is_null($urlpattern)) {
$this->getSession()->switchToWindow($windowNames[1]); $this->getSession()->switchToWindow($windowNames[1]);
$windowurl = $this->getSession()->getCurrentUrl(); $windowurl = $this->getSession()->getCurrentUrl();
$windowhaspattern = !!preg_match("/$urlpattern/", $windowurl); $windowhaspattern = (bool)preg_match("/$urlpattern/", $windowurl);
$this->getSession()->switchToWindow($windowNames[0]); $this->getSession()->switchToWindow($windowNames[0]);
if ($not === $windowhaspattern) { if ($not === $windowhaspattern) {
@ -885,6 +885,8 @@ class behat_app extends behat_app_helper {
case 'offline': case 'offline':
$this->runtime_js("network.setForceConnectionMode('none');"); $this->runtime_js("network.setForceConnectionMode('none');");
break; break;
default:
break;
} }
} }

View File

@ -412,12 +412,9 @@ class behat_app_helper extends behat_base {
preg_match_all("/\\$\\{([^:}]+):([^}]+)\\}/", $text, $matches); preg_match_all("/\\$\\{([^:}]+):([^}]+)\\}/", $text, $matches);
foreach ($matches[0] as $index => $match) { foreach ($matches[0] as $index => $match) {
switch ($matches[2][$index]) { if ($matches[2][$index] == 'cmid') {
case 'cmid': $coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]);
$coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]); $text = str_replace($match, $coursemodule->id, $text);
$text = str_replace($match, $coursemodule->id, $text);
break;
} }
} }
@ -550,7 +547,7 @@ class behat_app_helper extends behat_base {
if (!empty($successXPath)) { if (!empty($successXPath)) {
// Wait until the page appears. // Wait until the page appears.
$this->spin( $this->spin(
function($context, $args) use ($successXPath) { function($context) use ($successXPath) {
$found = $context->getSession()->getPage()->find('xpath', $successXPath); $found = $context->getSession()->getPage()->find('xpath', $successXPath);
if ($found) { if ($found) {
return true; return true;
@ -597,7 +594,6 @@ class behat_app_helper extends behat_base {
$cmfrom = $cmtable->get_from_sql(); $cmfrom = $cmtable->get_from_sql();
$acttable = new \core\dml\table($activity, 'a', 'a'); $acttable = new \core\dml\table($activity, 'a', 'a');
$actselect = $acttable->get_field_select();
$actfrom = $acttable->get_from_sql(); $actfrom = $acttable->get_from_sql();
$sql = <<<EOF $sql = <<<EOF
@ -662,7 +658,7 @@ EOF;
// Set up relevant tags for each version. // Set up relevant tags for each version.
$usedtags = array_keys($usedtags); $usedtags = array_keys($usedtags);
foreach ($usedtags as $usedtag) { foreach ($usedtags as $usedtag) {
if (!preg_match('~^lms_(from|upto)([0-9]+(?:\.[0-9]+)*)$~', $usedtag, $matches)) { if (!preg_match('~^lms_(from|upto)(\d+(?:\.\d+)*)$~', $usedtag, $matches)) {
// No match, ignore. // No match, ignore.
continue; continue;
} }

View File

@ -78,10 +78,8 @@ class behat_performance extends behat_base {
$spaceindex = strpos($text, ' '); $spaceindex = strpos($text, ' ');
$value = floatval(substr($text, 0, $spaceindex)); $value = floatval(substr($text, 0, $spaceindex));
switch (substr($text, $spaceindex + 1)) { if (substr($text, $spaceindex + 1) == 'seconds') {
case 'seconds': $value *= 1000;
$value *= 1000;
break;
} }
return $value; return $value;
@ -108,6 +106,8 @@ class behat_performance extends behat_base {
return function ($a, $b) { return function ($a, $b) {
return $a === $b; return $a === $b;
}; };
default:
break;
} }
} }

View File

@ -247,13 +247,13 @@ class performance_measure implements behat_app_listener {
* Analyse long tasks. * Analyse long tasks.
*/ */
private function analyseLongTasks(): void { private function analyseLongTasks(): void {
$blocking = 0; $blockingDuration = 0;
foreach ($this->longTasks as $longTask) { foreach ($this->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 { private function analysePerformanceLogs(): void {
global $CFG; global $CFG;
$scripting = 0; $scriptingDuration = 0;
$styling = 0; $stylingDuration = 0;
$networking = 0; $networkingCount = 0;
$logs = $this->getPerformanceLogs(); $logs = $this->getPerformanceLogs();
foreach ($logs as $log) { foreach ($logs as $log) {
// TODO this should filter by end time as well, but it seems like the timestamps are not // TODO this should filter by end time as well, but it seems like the timestamps are not
// working as expected. // working as expected.
if (($log['timestamp'] < $this->start)) { if ($log['timestamp'] < $this->start) {
continue; continue;
} }
@ -285,27 +285,27 @@ class performance_measure implements behat_app_listener {
$messagename = $message->params->name ?? ''; $messagename = $message->params->name ?? '';
if (in_array($messagename, ['FunctionCall', 'GCEvent', 'MajorGC', 'MinorGC', 'EvaluateScript'])) { if (in_array($messagename, ['FunctionCall', 'GCEvent', 'MajorGC', 'MinorGC', 'EvaluateScript'])) {
$scripting += $message->params->dur; $scriptingDuration += $message->params->dur;
continue; continue;
} }
if (in_array($messagename, ['UpdateLayoutTree', 'RecalculateStyles', 'ParseAuthorStyleSheet'])) { if (in_array($messagename, ['UpdateLayoutTree', 'RecalculateStyles', 'ParseAuthorStyleSheet'])) {
$styling += $message->params->dur; $stylingDuration += $message->params->dur;
continue; continue;
} }
if (in_array($messagename, ['XHRLoad']) && !str_starts_with($message->params->args->data->url, $CFG->behat_ionic_wwwroot)) { if (in_array($messagename, ['XHRLoad']) && !str_starts_with($message->params->args->data->url, $CFG->behat_ionic_wwwroot)) {
$networking++; $networkingCount++;
continue; continue;
} }
} }
$this->scripting = round($scripting / 1000); $this->scripting = round($scriptingDuration / 1000);
$this->styling = round($styling / 1000); $this->styling = round($stylingDuration / 1000);
$this->networking = $networking; $this->networking = $networkingCount;
} }
/** /**

View File

@ -93,7 +93,7 @@ async function main() {
} }
const newPath = featurePath.substring(0, featurePath.length - ('/tests/behat'.length)); 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 prefix = relative(behatTempFeaturesPath, newPath).replace(searchRegExp,'-') || 'core';
const featureFilename = prefix + '-' + basename(featureFile); const featureFilename = prefix + '-' + basename(featureFile);
renameSync(featureFile, behatFeaturesPath + '/' + featureFilename); renameSync(featureFile, behatFeaturesPath + '/' + featureFilename);

View File

@ -42,7 +42,7 @@ $versions = array('master', '310', '39', '38', '37', '36', '35', '34', '33', '32
$moodlespath = $argv[1]; $moodlespath = $argv[1];
$wsname = $argv[2]; $wsname = $argv[2];
$useparams = !!(isset($argv[3]) && $argv[3]); $useparams = (bool)(isset($argv[3]) && $argv[3]);
$pathseparator = '/'; $pathseparator = '/';
// Get the path to the script. // Get the path to the script.

View File

@ -39,7 +39,7 @@ if (!defined('SERIALIZED')) {
$moodlepath = $argv[1]; $moodlepath = $argv[1];
$wsname = $argv[2]; $wsname = $argv[2];
$useparams = !!(isset($argv[3]) && $argv[3]); $useparams = (bool)(isset($argv[3]) && $argv[3]);
define('CLI_SCRIPT', true); define('CLI_SCRIPT', true);

View File

@ -302,7 +302,7 @@ function build_lang($lang) {
$text = str_replace(['{{{', '}}}'], ['{{', '}}'], $text); $text = str_replace(['{{{', '}}}'], ['{{', '}}'], $text);
} else { } else {
// @TODO: Remove that line when core.cannotconnect and core.login.invalidmoodleversion are completelly changed to use $a // @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); $text = str_replace('2.4', '{{$a}}', $text);
} }
$local++; $local++;
@ -471,13 +471,10 @@ function override_component_lang_files($translations) {
} }
switch($type) { switch($type) {
case 'core': case 'core':
switch($component) { if ($component == 'moodle') {
case 'moodle': $path .= 'core/lang.json';
$path .= 'core/lang.json'; } else {
break; $path .= 'core/features/'.str_replace('_', '/', $component).'/lang.json';
default:
$path .= 'core/features/'.str_replace('_', '/', $component).'/lang.json';
break;
} }
break; break;
case 'addon': case 'addon':

View File

@ -70,7 +70,7 @@ function fix_comment($desc) {
if (count($lines) > 1) { if (count($lines) > 1) {
$desc = array_shift($lines)."\n"; $desc = array_shift($lines)."\n";
foreach ($lines as $i => $line) { foreach ($lines as $line) {
$spaces = strlen($line) - strlen(ltrim($line)); $spaces = strlen($line) - strlen(ltrim($line));
$desc .= str_repeat(' ', $spaces - 3) . '// '. ltrim($line)."\n"; $desc .= str_repeat(' ', $spaces - 3) . '// '. ltrim($line)."\n";
} }
@ -138,9 +138,7 @@ function convert_to_ts($key, $value, $boolisnumber = false, $indentation = '', $
$type = 'number'; $type = 'number';
} }
$result = convert_key_type($key, $type, $value->required, $indentation); return convert_key_type($key, $type, $value->required, $indentation);
return $result;
} else if ($value instanceof external_single_structure) { } else if ($value instanceof external_single_structure) {
// It's an object. // It's an object.
@ -278,7 +276,7 @@ function remove_default_closures($value) {
} else if ($value instanceof external_single_structure) { } else if ($value instanceof external_single_structure) {
foreach ($value->keys as $key => $subvalue) { foreach ($value->keys as $subvalue) {
remove_default_closures($subvalue); remove_default_closures($subvalue);
} }

View File

@ -369,14 +369,14 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
protected async refreshCourseList(data: CoreCoursesMyCoursesUpdatedEventData): Promise<void> { protected async refreshCourseList(data: CoreCoursesMyCoursesUpdatedEventData): Promise<void> {
if (data.action == CoreCoursesProvider.ACTION_ENROL) { if (data.action == CoreCoursesProvider.ACTION_ENROL) {
// Always update if user enrolled in a course. // 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); const course = this.allCourses.find((course) => course.id == data.courseId);
if (data.action == CoreCoursesProvider.ACTION_STATE_CHANGED) { if (data.action == CoreCoursesProvider.ACTION_STATE_CHANGED) {
if (!course) { if (!course) {
// Not found, use WS update. // Not found, use WS update.
return await this.refreshContent(); return this.refreshContent();
} }
if (data.state == CoreCoursesProvider.STATE_FAVOURITE) { 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 (data.action == CoreCoursesProvider.ACTION_VIEW && data.courseId != CoreSites.getCurrentSiteHomeId()) {
if (!course) { if (!course) {
// Not found, use WS update. // Not found, use WS update.
return await this.refreshContent(); return this.refreshContent();
} }
course.lastaccess = CoreTimeUtils.timestamp(); course.lastaccess = CoreTimeUtils.timestamp();

View File

@ -171,7 +171,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
protected async refreshCourseList(data: CoreCoursesMyCoursesUpdatedEventData): Promise<void> { protected async refreshCourseList(data: CoreCoursesMyCoursesUpdatedEventData): Promise<void> {
if (data.action == CoreCoursesProvider.ACTION_ENROL) { if (data.action == CoreCoursesProvider.ACTION_ENROL) {
// Always update if user enrolled in a course. // 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); 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 (data.action == CoreCoursesProvider.ACTION_VIEW && data.courseId != CoreSites.getCurrentSiteHomeId()) {
if (!course) { if (!course) {
// Not found, use WS update. // Not found, use WS update.
return await this.refreshContent(); return this.refreshContent();
} }
// Place at the begining. // Place at the begining.

View File

@ -159,14 +159,14 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
if (data.action == CoreCoursesProvider.ACTION_ENROL) { if (data.action == CoreCoursesProvider.ACTION_ENROL) {
// Always update if user enrolled in a course. // Always update if user enrolled in a course.
// New courses shouldn't be favourite by default, but just in case. // 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) { if (data.action == CoreCoursesProvider.ACTION_STATE_CHANGED && data.state == CoreCoursesProvider.STATE_FAVOURITE) {
const courseIndex = this.courses.findIndex((course) => course.id == data.courseId); const courseIndex = this.courses.findIndex((course) => course.id == data.courseId);
if (courseIndex < 0) { if (courseIndex < 0) {
// Not found, use WS update. Usually new favourite. // Not found, use WS update. Usually new favourite.
return await this.refreshContent(); return this.refreshContent();
} }
const course = this.courses[courseIndex]; const course = this.courses[courseIndex];

View File

@ -47,7 +47,7 @@ export class AddonBlockStarredCoursesProvider {
cacheKey: this.getStarredCoursesCacheKey(), cacheKey: this.getStarredCoursesCacheKey(),
}; };
return await site.read<AddonBlockStarredCourse[]>('block_starredcourses_get_starred_courses', undefined, preSets); return site.read<AddonBlockStarredCourse[]>('block_starredcourses_get_starred_courses', undefined, preSets);
} }
/** /**

View File

@ -74,7 +74,7 @@ export class AddonCalendarOfflineProvider {
async getAllDeletedEvents(siteId?: string): Promise<AddonCalendarOfflineDeletedEventDBRecord[]> { async getAllDeletedEvents(siteId?: string): Promise<AddonCalendarOfflineDeletedEventDBRecord[]> {
const site = await CoreSites.getSite(siteId); 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<AddonCalendarOfflineEventDBRecord[]> { async getAllEditedEvents(siteId?: string): Promise<AddonCalendarOfflineEventDBRecord[]> {
const site = await CoreSites.getSite(siteId); 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, 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, 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(), timemodified: Date.now(),
}; };
return await site.getDb().insertRecord(DELETED_EVENTS_TABLE, event); return site.getDb().insertRecord(DELETED_EVENTS_TABLE, event);
} }
/** /**

View File

@ -503,7 +503,7 @@ export class AddonCalendarProvider {
async getAllEventsFromLocalDb(siteId?: string): Promise<AddonCalendarEventDBRecord[]> { async getAllEventsFromLocalDb(siteId?: string): Promise<AddonCalendarEventDBRecord[]> {
const site = await CoreSites.getSite(siteId); 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<AddonCalendarReminderDBRecord[]> { async getEventReminders(id: number, siteId?: string): Promise<AddonCalendarReminderDBRecord[]> {
const site = await CoreSites.getSite(siteId); 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<AddonCalendarEventDBRecord[]> { async getLocalEventsByRepeatIdFromLocalDb(repeatId: number, siteId?: string): Promise<AddonCalendarEventDBRecord[]> {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
return await site.getDb().getRecords(EVENTS_TABLE, { repeatid: repeatId }); return site.getDb().getRecords(EVENTS_TABLE, { repeatid: repeatId });
} }
/** /**

View File

@ -57,7 +57,7 @@ export class AddonCourseCompletionUserHandlerService implements CoreUserProfileH
* @inheritdoc * @inheritdoc
*/ */
async isEnabledForUser(user: CoreUserProfile, context: CoreUserDelegateContext, contextId: number): Promise<boolean> { async isEnabledForUser(user: CoreUserProfile, context: CoreUserDelegateContext, contextId: number): Promise<boolean> {
return await AddonCourseCompletion.isPluginViewEnabledForUser(contextId, user.id); return AddonCourseCompletion.isPluginViewEnabledForUser(contextId, user.id);
} }
/** /**

View File

@ -34,7 +34,7 @@ export class AddonMessagesSettingsHandlerService implements CoreSettingsHandler
* @return Whether or not the handler is enabled on a site level. * @return Whether or not the handler is enabled on a site level.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
return await AddonMessages.isPluginEnabled(); return AddonMessages.isPluginEnabled();
} }
/** /**

View File

@ -1620,13 +1620,12 @@ export class AddonMessagesProvider {
preSets.emergencyCache = false; preSets.emergencyCache = false;
} }
return await this.getMessages(params, preSets, siteId); return this.getMessages(params, preSets, siteId);
} }
/** /**
* Invalidate all contacts cache. * Invalidate all contacts cache.
* *
* @param userId The user ID.
* @param siteId Site ID. If not defined, current site. * @param siteId Site ID. If not defined, current site.
* @return Resolved when done. * @return Resolved when done.
*/ */
@ -2517,7 +2516,7 @@ export class AddonMessagesProvider {
messages, 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);
} }
/** /**

View File

@ -389,7 +389,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
return; return;
} }
return await AddonModAssignSync.syncAssign(this.assign.id); return AddonModAssignSync.syncAssign(this.assign.id);
} }
/** /**

View File

@ -329,7 +329,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
// Cannot submit in online, prepare for offline usage. // Cannot submit in online, prepare for offline usage.
this.saveOffline = true; this.saveOffline = true;
return await AddonModAssignHelper.prepareSubmissionPluginData( return AddonModAssignHelper.prepareSubmissionPluginData(
this.assign!, this.assign!,
this.userSubmission, this.userSubmission,
inputData, inputData,

View File

@ -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, 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, timemodified: now,
}; };
return await site.getDb().insertRecord(SUBMISSIONS_GRADES_TABLE, entry); return site.getDb().insertRecord(SUBMISSIONS_GRADES_TABLE, entry);
} }
} }

View File

@ -203,7 +203,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate<AddonMod
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
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<AddonMod
async getComponentForPlugin( async getComponentForPlugin(
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
): Promise<Type<IAddonModAssignFeedbackPluginComponent> | undefined> { ): Promise<Type<IAddonModAssignFeedbackPluginComponent> | 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<AddonMod
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
siteId?: string, siteId?: string,
): Promise<T | undefined> { ): Promise<T | undefined> {
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<AddonMod
inputData: CoreFormFields, inputData: CoreFormFields,
userId: number, userId: number,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'hasDataChanged', 'hasDataChanged',
[assign, submission, plugin, inputData, userId], [assign, submission, plugin, inputData, userId],
@ -307,7 +307,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate<AddonMod
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
siteId?: string, siteId?: string,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
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<AddonMod
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
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<AddonMod
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'prepareFeedbackData', 'prepareFeedbackData',
[assignId, userId, plugin, pluginData, siteId], [assignId, userId, plugin, pluginData, siteId],
@ -380,7 +380,7 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate<AddonMod
inputData: CoreFormFields, inputData: CoreFormFields,
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'saveDraft', 'saveDraft',
[assignId, userId, plugin, inputData, siteId], [assignId, userId, plugin, inputData, siteId],

View File

@ -293,7 +293,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
submission: AddonModAssignSubmission, submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
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<AddonM
userId?: number, userId?: number,
siteId?: string, siteId?: string,
): Promise<void | undefined> { ): Promise<void | undefined> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'copySubmissionData', 'copySubmissionData',
[assign, plugin, pluginData, userId, siteId], [assign, plugin, pluginData, userId, siteId],
@ -354,7 +354,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
offlineData: AddonModAssignSubmissionsDBRecordFormatted, offlineData: AddonModAssignSubmissionsDBRecordFormatted,
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'deleteOfflineData', 'deleteOfflineData',
[assign, submission, plugin, offlineData, siteId], [assign, submission, plugin, offlineData, siteId],
@ -372,7 +372,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
edit?: boolean, edit?: boolean,
): Promise<Type<AddonModAssignSubmissionPluginBaseComponent> | undefined> { ): Promise<Type<AddonModAssignSubmissionPluginBaseComponent> | 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<AddonM
* @return Promise resolved with size. * @return Promise resolved with size.
*/ */
async getPluginSizeForCopy(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): Promise<number | undefined> { async getPluginSizeForCopy(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): Promise<number | undefined> {
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<AddonM
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
inputData: CoreFormFields, inputData: CoreFormFields,
): Promise<number | undefined> { ): Promise<number | undefined> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'getSizeForEdit', 'getSizeForEdit',
[assign, submission, plugin, inputData], [assign, submission, plugin, inputData],
@ -455,7 +455,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
inputData: CoreFormFields, inputData: CoreFormFields,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'hasDataChanged', 'hasDataChanged',
[assign, submission, plugin, inputData], [assign, submission, plugin, inputData],
@ -479,7 +479,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
* @return Whether it's supported for edit. * @return Whether it's supported for edit.
*/ */
async isPluginSupportedForEdit(pluginType: string): Promise<boolean | undefined> { async isPluginSupportedForEdit(pluginType: string): Promise<boolean | undefined> {
return await this.executeFunctionOnEnabled(pluginType, 'isEnabledForEdit'); return this.executeFunctionOnEnabled(pluginType, 'isEnabledForEdit');
} }
/** /**
@ -508,7 +508,7 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
siteId?: string, siteId?: string,
): Promise<void> { ): Promise<void> {
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<AddonM
siteId?: string, siteId?: string,
): Promise<void | undefined> { ): Promise<void | undefined> {
return await this.executeFunctionOnEnabled( return this.executeFunctionOnEnabled(
plugin.type, plugin.type,
'prepareSubmissionData', 'prepareSubmissionData',
[assign, submission, plugin, inputData, pluginData, offline, userId, siteId], [assign, submission, plugin, inputData, pluginData, offline, userId, siteId],

View File

@ -166,7 +166,7 @@ export class AddonModBBBService {
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
return await site.read<AddonModBBBMeetingInfoWSResponse>( return site.read<AddonModBBBMeetingInfoWSResponse>(
'mod_bigbluebuttonbn_meeting_info', 'mod_bigbluebuttonbn_meeting_info',
params, params,
preSets, preSets,

View File

@ -103,7 +103,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
num: number; num: number;
max: number; max: number;
reseturl: string; reseturl: string;
};; };
hasOfflineRatings = false; hasOfflineRatings = false;

View File

@ -225,7 +225,7 @@ export class AddonModFeedbackHelperProvider {
protected async addImageProfile( protected async addImageProfile(
entries: (AddonModFeedbackWSAttempt | AddonModFeedbackWSNonRespondent)[], entries: (AddonModFeedbackWSAttempt | AddonModFeedbackWSNonRespondent)[],
): Promise<(AddonModFeedbackAttempt | AddonModFeedbackNonRespondent)[]> { ): Promise<(AddonModFeedbackAttempt | AddonModFeedbackNonRespondent)[]> {
return await Promise.all(entries.map(async (entry: AddonModFeedbackAttempt | AddonModFeedbackNonRespondent) => { return Promise.all(entries.map(async (entry: AddonModFeedbackAttempt | AddonModFeedbackNonRespondent) => {
try { try {
const user = await CoreUser.getProfile(entry.userid, entry.courseid, true); const user = await CoreUser.getProfile(entry.userid, entry.courseid, true);

View File

@ -126,6 +126,8 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide
return; return;
} }
syncedDiscussionIds.push(reply.discussionid);
const result = force const result = force
? await this.syncDiscussionReplies(reply.discussionid, reply.userid, siteId) ? await this.syncDiscussionReplies(reply.discussionid, reply.userid, siteId)
: await this.syncDiscussionRepliesIfNeeded(reply.discussionid, reply.userid, siteId); : await this.syncDiscussionRepliesIfNeeded(reply.discussionid, reply.userid, siteId);

View File

@ -119,7 +119,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
throw new Error('Failed getting discussions'); throw new Error('Failed getting discussions');
} }
return await Promise.all( return Promise.all(
response.discussions.map((discussion) => AddonModForum.getDiscussionPosts(discussion.discussion, options)), response.discussions.map((discussion) => AddonModForum.getDiscussionPosts(discussion.discussion, options)),
); );
})); }));

View File

@ -673,7 +673,7 @@ export class AddonModGlossaryProvider {
* @return Promise resolved with all entrries. * @return Promise resolved with all entrries.
*/ */
fetchAllEntries( fetchAllEntries(
fetchFunction: (options?: AddonModGlossaryGetEntriesOptions) => AddonModGlossaryGetEntriesWSResponse, fetchFunction: (options?: AddonModGlossaryGetEntriesOptions) => Promise<AddonModGlossaryGetEntriesWSResponse>,
options: CoreCourseCommonModWSOptions = {}, options: CoreCourseCommonModWSOptions = {},
): Promise<AddonModGlossaryEntry[]> { ): Promise<AddonModGlossaryEntry[]> {
options.siteId = options.siteId || CoreSites.getCurrentSiteId(); options.siteId = options.siteId || CoreSites.getCurrentSiteId();
@ -681,7 +681,7 @@ export class AddonModGlossaryProvider {
const entries: AddonModGlossaryEntry[] = []; const entries: AddonModGlossaryEntry[] = [];
const fetchMoreEntries = async (): Promise<AddonModGlossaryEntry[]> => { const fetchMoreEntries = async (): Promise<AddonModGlossaryEntry[]> => {
const result = fetchFunction({ const result = await fetchFunction({
from: entries.length, from: entries.length,
...options, // Include all options. ...options, // Include all options.
}); });

View File

@ -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());
} }
/** /**

View File

@ -143,7 +143,7 @@ export class AddonModH5PActivityUsersAttemptsPage implements OnInit {
h5pActivity: AddonModH5PActivityData, h5pActivity: AddonModH5PActivityData,
users: AddonModH5PActivityUserAttempts[], users: AddonModH5PActivityUserAttempts[],
): Promise<AddonModH5PActivityUserAttemptsFormatted[]> { ): Promise<AddonModH5PActivityUserAttemptsFormatted[]> {
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); user.user = await CoreUser.getProfile(user.userid, this.courseId, true);
// Calculate the score of the user. // Calculate the score of the user.

View File

@ -214,7 +214,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo
// Update the view. // Update the view.
prefetched ? prefetched ?
this.showLoadingAndFetch(false, false) : this.showLoadingAndFetch(false, false) :
this.showLoadingAndRefresh(false);; this.showLoadingAndRefresh(false);
} catch { } catch {
// Prefetch failed, refresh the data. // Prefetch failed, refresh the data.
this.showLoadingAndRefresh(false); this.showLoadingAndRefresh(false);

View File

@ -115,7 +115,7 @@ export class AddonNotesOfflineProvider {
const site = await CoreSites.getSite(siteId); 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<AddonNotesDBRecord[]> { async getNotesForUser(userId: number, siteId?: string): Promise<AddonNotesDBRecord[]> {
const site = await CoreSites.getSite(siteId); 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<AddonNotesDBRecord[]> { async getNotesWithPublishState(state: AddonNotesPublishState, siteId?: string): Promise<AddonNotesDBRecord[]> {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
return await site.getDb().getRecords(NOTES_TABLE, { publishstate: state }); return site.getDb().getRecords(NOTES_TABLE, { publishstate: state });
} }
/** /**

View File

@ -177,7 +177,7 @@ export class AddonNotesProvider {
throw error; throw error;
} }
return await storeOffline(); return storeOffline();
} }
} }

View File

@ -60,7 +60,7 @@ export class AddonRemoteThemesHandlerService implements CoreStyleHandler {
} }
// Config received, it's a temp site. // Config received, it's a temp site.
return await this.getRemoteStyles(config.mobilecssurl); return this.getRemoteStyles(config.mobilecssurl);
} }
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
@ -108,7 +108,7 @@ export class AddonRemoteThemesHandlerService implements CoreStyleHandler {
return ''; return '';
} }
return await CoreWS.getText(url); return CoreWS.getText(url);
} }
/** /**

View File

@ -96,7 +96,7 @@ export class AddonReportInsightsActionLinkHandlerService extends CoreContentLink
return false; return false;
} }
return await AddonReportInsights.canSendActionInSite(siteId); return AddonReportInsights.canSendActionInSite(siteId);
} }
} }

View File

@ -41,7 +41,6 @@ const MOODLEAPP_VERSION_PREFIX = 'moodleapp-';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: 'app.component.html', templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
}) })
export class AppComponent implements OnInit, AfterViewInit { export class AppComponent implements OnInit, AfterViewInit {

View File

@ -13,9 +13,9 @@
// limitations under the License. // limitations under the License.
(function () { (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. // Same domain as the app, stop.
return; return;
} }
@ -41,14 +41,14 @@
}; };
// Handle link clicks. // Handle link clicks.
document.addEventListener('click', (event) => { document.addEventListener('click', (documentClickEvent) => {
if (event.defaultPrevented) { if (documentClickEvent.defaultPrevented) {
// Event already prevented by some other code. // Event already prevented by some other code.
return; return;
} }
// Find the link being clicked. // Find the link being clicked.
var el = event.target; let el = documentClickEvent.target;
while (el && (el.tagName !== 'A' && el.tagName !== 'a')) { while (el && (el.tagName !== 'A' && el.tagName !== 'a')) {
el = el.parentElement; 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. // 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.treated = true;
el.addEventListener('click', function(event) { el.addEventListener('click', function(elementClickEvent) {
linkClicked(el, event); linkClicked(el, elementClickEvent);
}); });
}, { }, {
capture: true // Use capture to fix this listener not called if the element clicked is too deep in the DOM. 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; return leftPath;
} }
var lastCharLeft = leftPath.slice(-1); const lastCharLeft = leftPath.slice(-1);
var firstCharRight = rightPath.charAt(0); const firstCharRight = rightPath.charAt(0);
if (lastCharLeft === '/' && firstCharRight === '/') { if (lastCharLeft === '/' && firstCharRight === '/') {
return leftPath + rightPath.substr(1); return leftPath + rightPath.substr(1);
@ -119,7 +119,7 @@
return; return;
} }
var matches = url.match(/^([a-z][a-z0-9+\-.]*):/); const matches = url.match(/^([a-z][a-z0-9+\-.]*):/);
if (matches && matches[1]) { if (matches && matches[1]) {
return matches[1]; return matches[1];
} }
@ -164,9 +164,9 @@
return; return;
} }
var linkScheme = getUrlScheme(link.href); const linkScheme = getUrlScheme(link.href);
var pageScheme = getUrlScheme(location.href); const pageScheme = getUrlScheme(location.href);
var isTargetSelf = !link.target || link.target == '_self'; const isTargetSelf = !link.target || link.target == '_self';
if (!link.href || linkScheme == 'javascript') { if (!link.href || linkScheme == 'javascript') {
// Links with no URL and Javascript links are ignored. // 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. // 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); return concatenatePaths(pathToDir, url);
} }

View File

@ -2134,7 +2134,7 @@ export class CoreSite {
async getLastViewed(component: string, id: number): Promise<CoreSiteLastViewedDBRecord | undefined> { async getLastViewed(component: string, id: number): Promise<CoreSiteLastViewedDBRecord | undefined> {
try { try {
return await this.lastViewedTable.getOneByPrimaryKey({ component, id }); return await this.lastViewedTable.getOneByPrimaryKey({ component, id });
} catch (error) { } catch {
// Not found. // Not found.
} }
} }
@ -2162,7 +2162,7 @@ export class CoreSite {
sqlParams: whereAndParams.params, sqlParams: whereAndParams.params,
js: (record) => record.component === component && ids.includes(record.id), js: (record) => record.component === component && ids.includes(record.id),
}); });
} catch (error) { } catch {
// Not found. // Not found.
} }
} }

View File

@ -569,7 +569,7 @@ export class CoreTabsBaseComponent<T extends CoreTabBase> implements OnInit, Aft
* @inheritdoc * @inheritdoc
*/ */
async ready(): Promise<void> { async ready(): Promise<void> {
return await this.onReadyPromise; return this.onReadyPromise;
} }
/** /**

View File

@ -116,7 +116,7 @@ export class CoreCommentsOfflineProvider {
async getAllDeletedComments(siteId?: string): Promise<CoreCommentsDeletedDBRecord[]> { async getAllDeletedComments(siteId?: string): Promise<CoreCommentsDeletedDBRecord[]> {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
return await site.getDb().getRecords(COMMENTS_DELETED_TABLE); return site.getDb().getRecords(COMMENTS_DELETED_TABLE);
} }
/** /**

View File

@ -176,7 +176,7 @@ export class CoreCommentsProvider {
comments: comments, comments: comments,
}; };
return await site.write('core_comment_add_comments', data); return site.write('core_comment_add_comments', data);
} }
/** /**

View File

@ -301,7 +301,7 @@ export class CoreContentLinksDelegateService {
return true; return true;
} }
return await handler.isEnabled(siteId, url, params, courseId); return handler.isEnabled(siteId, url, params, courseId);
} }
/** /**

View File

@ -60,7 +60,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
removeFilesLoading = false; removeFilesLoading = false;
prefetchLoading = false; prefetchLoading = false;
canPrefetch = false;; canPrefetch = false;
prefetchDisabled = false; prefetchDisabled = false;
size?: number; // Size in bytes size?: number; // Size in bytes
downloadTimeReadable = ''; // Last download time in a readable format. downloadTimeReadable = ''; // Last download time in a readable format.

View File

@ -1017,10 +1017,10 @@ export class CoreCourseHelperProvider {
if (prefetchHandler) { if (prefetchHandler) {
// Use the prefetch handler to download the module. // Use the prefetch handler to download the module.
if (prefetchHandler.download) { 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. // There's no prefetch handler for the module, just download the files.

View File

@ -46,7 +46,7 @@ export class CoreCourseOfflineProvider {
async getAllManualCompletions(siteId?: string): Promise<CoreCourseManualCompletionDBRecord[]> { async getAllManualCompletions(siteId?: string): Promise<CoreCourseManualCompletionDBRecord[]> {
const site = await CoreSites.getSite(siteId); 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<CoreCourseManualCompletionDBRecord[]> { async getCourseManualCompletions(courseId: number, siteId?: string): Promise<CoreCourseManualCompletionDBRecord[]> {
const site = await CoreSites.getSite(siteId); 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<CoreCourseManualCompletionDBRecord> { async getManualCompletion(cmId: number, siteId?: string): Promise<CoreCourseManualCompletionDBRecord> {
const site = await CoreSites.getSite(siteId); 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 });
} }
/** /**

View File

@ -484,7 +484,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate<CoreCourseOpt
// Load course options if missing. // Load course options if missing.
await this.loadCourseOptions(course, refresh); await this.loadCourseOptions(course, refresh);
return await this.hasHandlersForDefault(course.id, refresh, course.navOptions, course.admOptions); return this.hasHandlersForDefault(course.id, refresh, course.navOptions, course.admOptions);
} }
/** /**

View File

@ -978,7 +978,7 @@ export class CoreCourseProvider {
async getViewedModules(courseId: number, siteId?: string): Promise<CoreCourseViewedModulesDBRecord[]> { async getViewedModules(courseId: number, siteId?: string): Promise<CoreCourseViewedModulesDBRecord[]> {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
return await this.viewedModulesTables[site.getId()].getMany({ courseId }, { return this.viewedModulesTables[site.getId()].getMany({ courseId }, {
sorting: [ sorting: [
{ timeaccess: 'desc' }, { timeaccess: 'desc' },
], ],

View File

@ -394,7 +394,7 @@ export class CoreCourseFormatDelegateService extends CoreDelegate<CoreCourseForm
* @return Whether course view should be refreshed when an activity completion changes. * @return Whether course view should be refreshed when an activity completion changes.
*/ */
async shouldRefreshWhenCompletionChanges(course: CoreCourseAnyCourseData): Promise<boolean | undefined> { async shouldRefreshWhenCompletionChanges(course: CoreCourseAnyCourseData): Promise<boolean | undefined> {
return await this.executeFunctionOnEnabled(course.format || '', 'shouldRefreshWhenCompletionChanges', [course]); return this.executeFunctionOnEnabled(course.format || '', 'shouldRefreshWhenCompletionChanges', [course]);
} }
} }

View File

@ -326,7 +326,7 @@ export class CoreCourseModuleDelegateService extends CoreDelegate<CoreCourseModu
courseId: number, courseId: number,
options?: CoreNavigationOptions, options?: CoreNavigationOptions,
): Promise<void> { ): Promise<void> {
return await this.executeFunctionOnEnabled<void>( return this.executeFunctionOnEnabled<void>(
modname, modname,
'openActivityPage', 'openActivityPage',
[module, courseId, options], [module, courseId, options],

View File

@ -103,7 +103,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
} }
if (handler.canUseCheckUpdates) { if (handler.canUseCheckUpdates) {
return await handler.canUseCheckUpdates(module, courseId); return handler.canUseCheckUpdates(module, courseId);
} }
// By default, modules can use check updates. // By default, modules can use check updates.
@ -510,7 +510,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
if (handler?.getFiles) { if (handler?.getFiles) {
// The handler defines a function to get files, use it. // The handler defines a function to get files, use it.
return await handler.getFiles(module, courseId); return handler.getFiles(module, courseId);
} else if (handler?.loadContents) { } else if (handler?.loadContents) {
// The handler defines a function to load contents, use it before returning module contents. // The handler defines a function to load contents, use it before returning module contents.
await handler.loadContents(module, courseId); await handler.loadContents(module, courseId);
@ -1000,7 +1000,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
if (handler?.hasUpdates) { if (handler?.hasUpdates) {
// Handler implements its own function to check the updates, use it. // Handler implements its own function to check the updates, use it.
return await handler.hasUpdates(module, courseId, moduleUpdates); return handler.hasUpdates(module, courseId, moduleUpdates);
} else if (!moduleUpdates || !moduleUpdates.updates || !moduleUpdates.updates.length) { } else if (!moduleUpdates || !moduleUpdates.updates || !moduleUpdates.updates.length) {
// Module doesn't have any update. // Module doesn't have any update.
return false; return false;

View File

@ -666,7 +666,7 @@ export class CoreCoursesProvider {
cacheKey: this.getRecentCoursesCacheKey(userId), cacheKey: this.getRecentCoursesCacheKey(userId),
}; };
return await site.read<CoreCourseSummaryData[]>('core_course_get_recent_courses', params, preSets); return site.read<CoreCourseSummaryData[]>('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. * Get the common part of the cache keys for user navigation options WS calls.
* *
* @param courseIds IDs of courses to get.
* @return Cache key. * @return Cache key.
*/ */
protected getUserNavigationOptionsCommonCacheKey(): string { protected getUserNavigationOptionsCommonCacheKey(): string {

View File

@ -145,7 +145,7 @@ export class CoreCoursesDashboardProvider {
): Promise<void> { ): Promise<void> {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
return await site.invalidateWsCacheForKey(this.getDashboardBlocksCacheKey(myPage, userId)); return site.invalidateWsCacheForKey(this.getDashboardBlocksCacheKey(myPage, userId));
} }
/** /**

View File

@ -16,7 +16,7 @@
<core-empty-box *ngIf="rows && rows.length === 0" icon="fas-chart-bar" [message]="'core.grades.nogradesreturned' | translate"> <core-empty-box *ngIf="rows && rows.length === 0" icon="fas-chart-bar" [message]="'core.grades.nogradesreturned' | translate">
</core-empty-box> </core-empty-box>
<div *ngIf="rows && rows.length > 0" class="core-grades-container"> <div *ngIf="rows && rows.length > 0" class="core-grades-container">
<table cellspacing="0" cellpadding="0" class="core-grades-table" [class.summary]="showSummary"> <table class="core-grades-table" [class.summary]="showSummary">
<thead> <thead>
<tr> <tr>
<th *ngFor="let column of columns" id="{{column.name}}" class="ion-text-start" <th *ngFor="let column of columns" id="{{column.name}}" class="ion-text-start"

View File

@ -442,7 +442,7 @@ export class CoreGradesHelperProvider {
// Find href containing "/mod/xxx/xxx.php". // Find href containing "/mod/xxx/xxx.php".
const regex = /href="([^"]*\/mod\/[^"|^/]*\/[^"|^.]*\.php[^"]*)/; const regex = /href="([^"]*\/mod\/[^"|^/]*\/[^"|^.]*\.php[^"]*)/;
return await Promise.all(table.tabledata.filter((row) => { return Promise.all(table.tabledata.filter((row) => {
if (row.itemname && row.itemname.content) { if (row.itemname && row.itemname.content) {
const matches = row.itemname.content.match(regex); const matches = row.itemname.content.match(regex);

View File

@ -108,7 +108,7 @@ export class CoreGradesProvider {
userId = userId || site.getUserId(); userId = userId || site.getUserId();
return await this.getCourseGradesItems(courseId, userId, groupId, siteId, ignoreCache); return this.getCourseGradesItems(courseId, userId, groupId, siteId, ignoreCache);
} }
/** /**

View File

@ -75,7 +75,7 @@ export class CoreTagAreaDelegateService extends CoreDelegate<CoreTagAreaHandler>
async parseContent(component: string, itemType: string, content: string): Promise<unknown[] | undefined> { async parseContent(component: string, itemType: string, content: string): Promise<unknown[] | undefined> {
const type = component + '/' + itemType; 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<CoreTagAreaHandler>
async getComponent(component: string, itemType: string): Promise<Type<unknown> | undefined> { async getComponent(component: string, itemType: string): Promise<Type<unknown> | undefined> {
const type = component + '/' + itemType; const type = component + '/' + itemType;
return await this.executeFunctionOnEnabled(type, 'getComponent'); return this.executeFunctionOnEnabled(type, 'getComponent');
} }
} }

View File

@ -139,7 +139,7 @@ export class CoreUserProfileFieldDelegateService extends CoreDelegate<CoreUserPr
const name = 'profile_field_' + field.shortname; const name = 'profile_field_' + field.shortname;
if (handler.getData) { if (handler.getData) {
return await handler.getData(field, signup, registerAuth, formValues); return handler.getData(field, signup, registerAuth, formValues);
} else if (field.shortname && formValues[name] !== undefined) { } else if (field.shortname && formValues[name] !== undefined) {
// Handler doesn't implement the function, but the form has data for the field. // Handler doesn't implement the function, but the form has data for the field.
return { return {

View File

@ -242,7 +242,7 @@ export class CoreLangProvider {
// Get current language from config (user might have changed it). // Get current language from config (user might have changed it).
try { try {
return await CoreConfig.get<string>('current_language'); return await CoreConfig.get<string>('current_language');
} catch (e) { } catch {
// Try will return, ignore errors here to avoid nesting. // Try will return, ignore errors here to avoid nesting.
} }

View File

@ -1260,7 +1260,7 @@ export class CoreSitesProvider {
async getSitesInstances(): Promise<CoreSite[]> { async getSitesInstances(): Promise<CoreSite[]> {
const siteIds = await this.getSitesIds(); 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. * @return Promise resolved with config if available.
*/ */
protected async getSiteConfig(site: CoreSite): Promise<CoreSiteConfig | undefined> { protected async getSiteConfig(site: CoreSite): Promise<CoreSiteConfig | undefined> {
return await site.getConfig(undefined, true); return site.getConfig(undefined, true);
} }
/** /**

View File

@ -100,7 +100,7 @@ export class CoreSyncProvider {
async getSyncRecord(component: string, id: string | number, siteId?: string): Promise<CoreSyncRecord> { async getSyncRecord(component: string, id: string | number, siteId?: string): Promise<CoreSyncRecord> {
const db = await CoreSites.getSiteDb(siteId); 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) });
} }
/** /**

View File

@ -1782,7 +1782,7 @@ export class CoreDomUtilsProvider {
leaveAnimation: CoreModalLateralTransitionLeave, leaveAnimation: CoreModalLateralTransitionLeave,
}, options); }, options);
return await this.openModal<T>(options); return this.openModal<T>(options);
} }
/** /**

View File

@ -689,7 +689,7 @@ export class CoreUtilsProvider {
throw new Error('Countries not found.'); 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. * @return Promise resolved with the captured text or undefined if cancelled or error.
*/ */
async scanQR(title?: string): Promise<string | undefined> { async scanQR(title?: string): Promise<string | undefined> {
return await CoreDomUtils.openModal<string>({ return CoreDomUtils.openModal<string>({
component: CoreViewerQRScannerComponent, component: CoreViewerQRScannerComponent,
cssClass: 'core-modal-fullscreen', cssClass: 'core-modal-fullscreen',
componentProps: { componentProps: {

View File

@ -175,7 +175,7 @@ export class CoreDom {
slot.removeEventListener('slotchange', slotListener); slot.removeEventListener('slotchange', slotListener);
}; };
slot.addEventListener('slotchange', slotListener);; slot.addEventListener('slotchange', slotListener);
} }
/** /**