Skip to content

Commit

Permalink
Merge pull request #4127 from crazyserver/MOBILE-4616
Browse files Browse the repository at this point in the history
Mobile 4616
  • Loading branch information
dpalou authored Jul 25, 2024
2 parents 0c3dfc6 + 1186694 commit beac119
Show file tree
Hide file tree
Showing 171 changed files with 1,449 additions and 1,128 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ jobs:
cat circular-dependencies
lines=$(cat circular-dependencies | wc -l)
echo "Total circular dependencies: $lines"
test $lines -ge 138
test $lines -le 148
test $lines -eq 135
- name: JavaScript code compatibility
run: |
npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Object.hasOwn"
Expand Down
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ module.exports = {
testMatch: ['**/?(*.)test.ts'],
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.{test,stories}.ts',
'!src/**/*.test.ts',
'!src/assets/**/*',
'!src/testing/**/*',
'!src/storybook/**/*',
'!src/core/initializers/index.ts',
'!src/core/features/emulators/services/zip.ts',
],
Expand Down
2 changes: 1 addition & 1 deletion local_moodleappbehat/tests/behat/behat_app_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ protected function handle_url(string $customurl, string $successXPath = '') {
$result = $this->zone_js("customUrlSchemes.handleCustomURL('$customurl')");

if ($result !== 'OK') {
throw new DriverException('Error handling url - ' . $result);
throw new DriverException('Error handling url - ' . $customurl . ' - '.$result);
}
if (!empty($successXPath)) {
// Wait until the page appears.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Translate } from '@singletons';
import { CoreUtils } from '@services/utils/utils';
import { CoreNavigator } from '@services/navigator';
import { CoreCourseHelper } from '@features/course/services/course-helper';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreSharedModule } from '@/core/shared.module';

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i
brandedIcons[mod.modname] = mod.branded;

// If this is not a theme image, leave it undefined to avoid having specific activity icons.
if (CoreUrlUtils.isThemeImageUrl(mod.modicon)) {
if (CoreUrl.isThemeImageUrl(mod.modicon)) {
modIcons[mod.modname] = mod.modicon;
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/addons/blog/pages/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreArray } from '@singletons/array';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
Expand Down Expand Up @@ -79,7 +79,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy {
...this.filter,
category: 'blog',
},
url: CoreUrlUtils.addParamsToUrl('/blog/index.php', {
url: CoreUrl.addParamsToUrl('/blog/index.php', {
...this.filter,
modid: this.filter.cmid,
cmid: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/addons/calendar/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
import { CoreSwipeSlidesDynamicItemsManager } from '@classes/items-management/swipe-slides-dynamic-items-manager';
import moment from 'moment-timezone';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreTime } from '@singletons/time';
import { Translate } from '@singletons';

Expand Down Expand Up @@ -132,7 +132,7 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro
...params,
category: 'calendar',
},
url: CoreUrlUtils.addParamsToUrl('/calendar/view.php?view=month', params),
url: CoreUrl.addParamsToUrl('/calendar/view.php?view=month', params),
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { AddonCalendarOffline } from '../../services/calendar-offline';
import { CoreCategoryData, CoreCourses } from '@features/courses/services/courses';
import { CoreConstants } from '@/core/constants';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreTime } from '@singletons/time';
import { Translate } from '@singletons';

Expand Down Expand Up @@ -103,7 +103,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, DoCheck, On
...params,
category: 'calendar',
},
url: CoreUrlUtils.addParamsToUrl('/calendar/view.php?view=upcoming', params),
url: CoreUrl.addParamsToUrl('/calendar/view.php?view=upcoming', params),
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/addons/calendar/pages/day/day.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
import { AddonCalendarEventsSource } from '@addons/calendar/classes/events-source';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreTime } from '@singletons/time';

/**
Expand Down Expand Up @@ -201,7 +201,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
...params,
category: 'calendar',
},
url: CoreUrlUtils.addParamsToUrl('/calendar/view.php?view=day', params),
url: CoreUrl.addParamsToUrl('/calendar/view.php?view=day', params),
});
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/addons/calendar/services/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { CoreSite } from '@classes/sites/site';
import { CoreNetwork } from '@services/network';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreGroups } from '@services/groups';
import { CoreLocalNotifications } from '@services/local-notifications';
Expand Down Expand Up @@ -362,14 +362,14 @@ export class AddonCalendarProvider {
// Add links to the days if needed.
if (dayStart && (!seenDay || !moment(seenDay).isSame(start, 'day'))) {
promises.push(this.getViewUrl('day', event.timestart, undefined, siteId).then((url) => {
dayStart = CoreUrlUtils.buildLink(url, dayStart);
dayStart = CoreUrl.buildLink(url, dayStart);

return;
}));
}
if (dayEnd && (!seenDay || !moment(seenDay).isSame(end, 'day'))) {
promises.push(this.getViewUrl('day', end / 1000, undefined, siteId).then((url) => {
dayEnd = CoreUrlUtils.buildLink(url, dayEnd);
dayEnd = CoreUrl.buildLink(url, dayEnd);

return;
}));
Expand Down Expand Up @@ -398,7 +398,7 @@ export class AddonCalendarProvider {
// Add link to view the day.
const url = await this.getViewUrl('day', event.timestart, undefined, siteId);

return CoreUrlUtils.buildLink(url, this.getDayRepresentation(start, useCommonWords)) + ', ' + time;
return CoreUrl.buildLink(url, this.getDayRepresentation(start, useCommonWords)) + ', ' + time;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/addons/competency/pages/competency/competency.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
import { AddonCompetencyCourseCompetenciesSource } from '@addons/competency/classes/competency-course-competencies-source';
import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';

/**
* Page that displays the competency information.
Expand Down Expand Up @@ -306,7 +306,7 @@ export class AddonCompetencyCompetencyPage implements OnInit, OnDestroy {
planstatus: this.planStatus,
userid: userId,
},
url: CoreUrlUtils.addParamsToUrl('/admin/tool/lp/user_competency_in_plan.php', {
url: CoreUrl.addParamsToUrl('/admin/tool/lp/user_competency_in_plan.php', {
planid: source.PLAN_ID,
userid: userId,
competencyid: compId,
Expand All @@ -328,7 +328,7 @@ export class AddonCompetencyCompetencyPage implements OnInit, OnDestroy {
courseid: source.COURSE_ID,
userid: userId,
},
url: CoreUrlUtils.addParamsToUrl('/admin/tool/lp/user_competency_in_course.php', {
url: CoreUrl.addParamsToUrl('/admin/tool/lp/user_competency_in_course.php', {
courseid: source.COURSE_ID,
competencyid: compId,
userid: userId,
Expand Down
4 changes: 2 additions & 2 deletions src/addons/competency/services/handlers/push-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { COURSE_PAGE_NAME } from '@features/course/constants';
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
import { CoreNavigator } from '@services/navigator';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
Expand Down Expand Up @@ -49,7 +49,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
* @inheritdoc
*/
async handleClick(notification: AddonCompetencyPushNotificationData): Promise<void> {
const contextUrlParams = CoreUrlUtils.extractUrlParams(notification.contexturl);
const contextUrlParams = CoreUrl.extractUrlParams(notification.contexturl);

if (notification.name == 'competencyplancomment') {
// Open the learning plan.
Expand Down
4 changes: 2 additions & 2 deletions src/addons/filter/displayh5p/services/handlers/displayh5p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/def
import { CoreFilterFilter, CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { makeSingleton } from '@singletons';
import { CoreH5PPlayerComponent } from '@features/h5p/components/h5p-player/h5p-player';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { CoreH5PHelper } from '@features/h5p/classes/helper';

/**
Expand Down Expand Up @@ -57,7 +57,7 @@ export class AddonFilterDisplayH5PHandlerService extends CoreFilterDefaultHandle

embeddedH5PIframes.forEach((iframe) => {
// Add the preventredirect param to allow authenticating if auto-login fails.
iframe.src = CoreUrlUtils.addParamsToUrl(iframe.src, { preventredirect: false });
iframe.src = CoreUrl.addParamsToUrl(iframe.src, { preventredirect: false });

// Add resizer script so the H5P has the right height.
CoreH5PHelper.addResizerScript();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreEvents } from '@singletons/events';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
import { CoreWait } from '@singletons/wait';

/**
* Handler to support the MathJax filter.
Expand Down Expand Up @@ -321,7 +322,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
return;
}

await CoreUtils.wait(250);
await CoreWait.wait(250);
await CoreUtils.ignoreErrors(this.waitForReady(retries + 1));
}

Expand Down
4 changes: 2 additions & 2 deletions src/addons/filter/mediaplugin/services/videojs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { CorePromisedValue } from '@classes/promised-value';
import { CoreExternalContentDirective } from '@directives/external-content';
import { CoreLang } from '@services/lang';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUrl } from '@singletons/url';
import { makeSingleton } from '@singletons';
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
import { CoreEvents } from '@singletons/events';
Expand Down Expand Up @@ -107,7 +107,7 @@ export class AddonFilterMediaPluginVideoJSService {

const dataSetupString = video.getAttribute('data-setup') || video.getAttribute('data-setup-lazy') || '{}';
const data = CoreTextUtils.parseJSON<VideoJSOptions>(dataSetupString, {});
const youtubeUrl = data.techOrder?.[0] == 'youtube' && CoreUrlUtils.getYoutubeEmbedUrl(data.sources?.[0]?.src);
const youtubeUrl = data.techOrder?.[0] == 'youtube' && CoreUrl.getYoutubeEmbedUrl(data.sources?.[0]?.src);

if (!youtubeUrl) {
return;
Expand Down
8 changes: 5 additions & 3 deletions src/addons/messages/pages/discussion/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import { ActivatedRoute } from '@angular/router';
import { CoreConstants } from '@/core/constants';
import { CoreDom } from '@singletons/dom';
import { CoreKeyboard } from '@singletons/keyboard';
import { CoreText } from '@singletons/text';
import { CoreWait } from '@singletons/wait';

/**
* Page that displays a message discussion page.
Expand Down Expand Up @@ -883,7 +885,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
return;
}

await CoreUtils.wait(400);
await CoreWait.wait(400);
await CoreUtils.ignoreErrors(this.waitForFetch());
}

Expand Down Expand Up @@ -924,7 +926,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
*/
copyMessage(message: AddonMessagesConversationMessageFormatted): void {
const text = 'smallmessage' in message ? message.smallmessage || message.text || '' : message.text || '';
CoreUtils.copyToClipboard(CoreTextUtils.decodeHTMLEntities(text));
CoreText.copyToClipboard(CoreTextUtils.decodeHTMLEntities(text));
}

/**
Expand Down Expand Up @@ -1071,7 +1073,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
this.setNewMessagesBadge(0);

// Leave time for the view to be rendered.
await CoreUtils.nextTicks(5);
await CoreWait.nextTicks(5);

if (!this.viewDestroyed && this.content) {
this.content.scrollToBottom(0);
Expand Down
3 changes: 2 additions & 1 deletion src/addons/messages/services/messages-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { CoreUser } from '@features/user/services/user';
import { CoreError } from '@classes/errors/error';
import { CoreTextErrorObject, CoreTextUtils } from '@services/utils/text';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreWait } from '@singletons/wait';

/**
* Service to sync messages.
Expand Down Expand Up @@ -252,7 +253,7 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider<AddonMessage
// In some Moodle versions, wait 1 second to make sure timecreated is different.
// This is because there was a bug where messages with the same timecreated had a wrong order.
if (!groupMessagingEnabled && i < messages.length - 1) {
await CoreUtils.wait(1000);
await CoreWait.wait(1000);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Component, Input } from '@angular/core';
import { CoreCanceledError } from '@classes/errors/cancelederror';
import { CoreError } from '@classes/errors/error';
import { CoreDomUtils } from '@services/utils/dom';
import { AddonModAssignEditFeedbackModalComponent } from '../components/edit-feedback-modal/edit-feedback-modal';
import { AddonModAssignFeedbackCommentsTextData } from '../feedback/comments/services/handler';
import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } from '../services/assign';

Expand Down Expand Up @@ -46,6 +45,9 @@ export class AddonModAssignFeedbackPluginBaseComponent implements IAddonModAssig
throw new CoreError('Cannot edit feedback');
}

const { AddonModAssignEditFeedbackModalComponent } =
await import('@addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal');

// Create the navigation modal.
const modalData = await CoreDomUtils.openModal<AddonModAssignFeedbackCommentsTextData>({
component: AddonModAssignEditFeedbackModalComponent,
Expand Down
3 changes: 0 additions & 3 deletions src/addons/mod/assign/components/components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ import { AddonModAssignIndexComponent } from './index/index';
import { AddonModAssignSubmissionComponent } from './submission/submission';
import { AddonModAssignSubmissionPluginComponent } from './submission-plugin/submission-plugin';
import { AddonModAssignFeedbackPluginComponent } from './feedback-plugin/feedback-plugin';
import { AddonModAssignEditFeedbackModalComponent } from './edit-feedback-modal/edit-feedback-modal';

@NgModule({
declarations: [
AddonModAssignIndexComponent,
AddonModAssignSubmissionComponent,
AddonModAssignSubmissionPluginComponent,
AddonModAssignFeedbackPluginComponent,
AddonModAssignEditFeedbackModalComponent,
],
imports: [
CoreSharedModule,
Expand All @@ -39,7 +37,6 @@ import { AddonModAssignEditFeedbackModalComponent } from './edit-feedback-modal/
AddonModAssignSubmissionComponent,
AddonModAssignSubmissionPluginComponent,
AddonModAssignFeedbackPluginComponent,
AddonModAssignEditFeedbackModalComponent,
],
})
export class AddonModAssignComponentsModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ import { CoreUtils } from '@services/utils/utils';
import { ModalController, Translate } from '@singletons';
import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } from '../../services/assign';
import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate';
import { CoreSharedModule } from '@/core/shared.module';
import { AddonModAssignComponentsModule } from '../components.module';

/**
* Modal that allows editing a feedback plugin.
*/
@Component({
selector: 'addon-mod-assign-edit-feedback-modal',
templateUrl: 'edit-feedback-modal.html',
standalone: true,
imports: [
CoreSharedModule,
AddonModAssignComponentsModule,
],
})
export class AddonModAssignEditFeedbackModalComponent {

Expand Down
4 changes: 2 additions & 2 deletions src/addons/mod/assign/pages/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page';
import { AddonModAssignIndexComponent } from '../../components/index/index';
import { CoreNavigator } from '@services/navigator';
import { CoreUtils } from '@services/utils/utils';
import { CoreWait } from '@singletons/wait';

/**
* Page that displays an assign.
Expand Down Expand Up @@ -44,7 +44,7 @@ export class AddonModAssignIndexPage extends CoreCourseModuleMainActivityPage<Ad
async ngAfterViewInit(): Promise<void> {
switch (this.action) {
case 'editsubmission':
await CoreUtils.waitFor(() => !!this.activityComponent?.submissionComponent, { timeout: 5000 });
await CoreWait.waitFor(() => !!this.activityComponent?.submissionComponent, { timeout: 5000 });
await this.activityComponent?.submissionComponent?.goToEdit();

break;
Expand Down
Loading

0 comments on commit beac119

Please sign in to comment.