From 3afa736cf469e0373ff2c4da8341f6518ecccce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 18 Jul 2024 16:09:57 +0200 Subject: [PATCH] MOBILE-4616 loading: Create a service to have loading functions --- .github/workflows/testing.yml | 2 +- .../recentlyaccesseditems.ts | 4 +- .../timeline/components/events/events.ts | 4 +- .../blog/pages/edit-entry/edit-entry.ts | 3 +- src/addons/blog/pages/index/index.ts | 5 +- .../calendar/pages/edit-event/edit-event.ts | 5 +- src/addons/calendar/pages/event/event.ts | 8 +- .../coursecompletion/pages/report/report.ts | 3 +- .../enrol/guest/services/enrol-handler.ts | 4 +- .../enrol/self/services/enrol-handler.ts | 3 +- .../messages/pages/discussion/discussion.ts | 17 ++-- .../messages/pages/settings/settings.ts | 3 +- .../components/submission/submission.ts | 9 ++- src/addons/mod/assign/pages/edit/edit.ts | 7 +- .../bigbluebuttonbn/components/index/index.ts | 5 +- src/addons/mod/chat/pages/chat/chat.ts | 3 +- .../mod/chat/pages/sessions/sessions.ts | 3 +- .../mod/choice/components/index/index.ts | 5 +- .../data/fields/latlong/component/latlong.ts | 3 +- src/addons/mod/data/pages/edit/edit.ts | 3 +- src/addons/mod/data/services/data-helper.ts | 5 +- .../data/services/handlers/edit-link-lazy.ts | 4 +- .../data/services/handlers/show-link-lazy.ts | 4 +- src/addons/mod/feedback/pages/form/form.ts | 3 +- .../mod/feedback/services/feedback-helper.ts | 3 +- .../services/handlers/analysis-link.ts | 3 +- .../services/handlers/complete-link.ts | 3 +- .../feedback/services/handlers/print-link.ts | 3 +- .../handlers/show-non-respondents-link.ts | 3 +- .../discussion-options-menu.ts | 7 +- .../mod/forum/components/index/index.ts | 3 +- src/addons/mod/forum/components/post/post.ts | 5 +- .../mod/forum/pages/discussion/discussion.ts | 7 +- .../pages/new-discussion/new-discussion.ts | 3 +- .../mod/forum/services/handlers/post-link.ts | 4 +- src/addons/mod/glossary/pages/edit/edit.ts | 3 +- src/addons/mod/glossary/pages/entry/entry.ts | 3 +- .../glossary/services/handlers/edit-link.ts | 3 +- .../glossary/services/handlers/entry-link.ts | 3 +- .../services/handlers/report-link.ts | 3 +- .../lesson/services/handlers/grade-link.ts | 3 +- .../lesson/services/handlers/index-link.ts | 4 +- .../lesson/services/handlers/report-link.ts | 5 +- src/addons/mod/lti/services/lti-helper.ts | 3 +- src/addons/mod/quiz/pages/player/player.ts | 11 +-- src/addons/mod/quiz/services/quiz-helper.ts | 3 +- .../mod/resource/services/resource-helper.ts | 3 +- .../mod/survey/components/index/index.ts | 3 +- .../mod/url/services/handlers/module.ts | 4 +- src/addons/mod/url/services/url-helper.ts | 4 +- src/addons/mod/wiki/pages/edit/edit.ts | 3 +- .../services/handlers/create-link-lazy.ts | 3 +- .../wiki/services/handlers/edit-link-lazy.ts | 3 +- .../handlers/page-or-map-link-lazy.ts | 3 +- .../assessment-strategy.ts | 3 +- .../components/assessment/assessment.ts | 3 +- .../workshop/pages/assessment/assessment.ts | 3 +- .../pages/edit-submission/edit-submission.ts | 3 +- .../workshop/pages/submission/submission.ts | 5 +- src/addons/notes/components/add/add-modal.ts | 3 +- .../notifications/pages/settings/settings.ts | 3 +- .../services/privatefiles-helper.ts | 4 +- .../insights/services/handlers/action-link.ts | 3 +- .../pages/course-storage/course-storage.ts | 3 +- .../pages/courses-storage/courses-storage.ts | 5 +- src/core/classes/sites/site.ts | 3 +- src/core/components/local-file/local-file.ts | 5 +- .../password-modal/password-modal.ts | 4 +- src/core/core.module.ts | 2 + src/core/directives/download-file.ts | 3 +- src/core/directives/link.ts | 3 +- .../features/comments/pages/viewer/viewer.ts | 3 +- .../classes/module-grade-handler.ts | 4 +- .../module-navigation/module-navigation.ts | 3 +- .../directives/download-module-main-file.ts | 3 +- .../features/course/services/course-helper.ts | 9 ++- src/core/features/course/services/course.ts | 3 +- .../course-list-item/course-list-item.ts | 3 +- .../services/handlers/base-link-handler.ts | 4 +- .../services/handlers/enrol-push-click.ts | 3 +- .../services/handlers/request-push-click.ts | 3 +- .../components/contactdpo/contactdpo.ts | 5 +- .../components/newrequest/newrequest.ts | 3 +- .../features/dataprivacy/pages/main/main.ts | 7 +- .../components/capture-media/capture-media.ts | 5 +- .../services/fileuploader-helper.ts | 7 +- .../features/grades/services/grades-helper.ts | 3 +- .../login/pages/credentials/credentials.ts | 3 +- .../login/pages/email-signup/email-signup.ts | 5 +- .../forgotten-password/forgotten-password.ts | 3 +- .../login/pages/reconnect/reconnect.ts | 3 +- src/core/features/login/pages/site/site.ts | 7 +- src/core/features/login/pages/sites/sites.ts | 3 +- .../features/login/services/login-helper.ts | 11 +-- .../policy/pages/acceptances/acceptances.ts | 3 +- .../policy/pages/site-policy/site-policy.ts | 3 +- .../features/rating/components/rate/rate.ts | 3 +- src/core/features/settings/pages/dev/dev.ts | 2 +- .../classes/call-ws-click-directive.ts | 3 +- src/core/features/user/pages/about/about.ts | 3 +- src/core/services/loadings.ts | 78 +++++++++++++++++++ src/core/services/navigator.ts | 4 +- src/core/services/urlschemes.ts | 3 +- src/core/services/utils/dom.ts | 36 ++------- src/core/services/utils/iframe.ts | 3 +- src/testing/utils.ts | 6 +- 106 files changed, 339 insertions(+), 198 deletions(-) create mode 100644 src/core/services/loadings.ts diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 538b5de28..d6c708a28 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -69,7 +69,7 @@ jobs: cat circular-dependencies lines=$(cat circular-dependencies | wc -l) echo "Total circular dependencies: $lines" - test $lines -eq 129 + test $lines -eq 131 - name: JavaScript code compatibility run: | npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Object.hasOwn" diff --git a/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts b/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts index 8db3fa4a8..c56027c1d 100644 --- a/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts +++ b/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts @@ -20,7 +20,7 @@ import { AddonBlockRecentlyAccessedItemsItemCalculatedData, } from '../../services/recentlyaccesseditems'; import { CoreTextUtils } from '@services/utils/text'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreUtils } from '@services/utils/utils'; import { CoreSharedModule } from '@/core/shared.module'; @@ -93,7 +93,7 @@ export class AddonBlockRecentlyAccessedItemsComponent extends CoreBlockBaseCompo e.stopPropagation(); const url = CoreTextUtils.decodeHTMLEntities(item.viewurl); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await CoreSites.visitLink(url); diff --git a/src/addons/block/timeline/components/events/events.ts b/src/addons/block/timeline/components/events/events.ts index bb69312bc..5156464dc 100644 --- a/src/addons/block/timeline/components/events/events.ts +++ b/src/addons/block/timeline/components/events/events.ts @@ -14,7 +14,7 @@ import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreTextUtils } from '@services/utils/text'; import { CoreEnrolledCourseDataWithOptions } from '@features/courses/services/courses-helper'; import { AddonBlockTimelineDayEvents } from '@addons/block/timeline/classes/section'; @@ -66,7 +66,7 @@ export class AddonBlockTimelineEventsComponent implements OnInit { // Fix URL format. url = CoreTextUtils.decodeHTMLEntities(url); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await CoreSites.visitLink(url); diff --git a/src/addons/blog/pages/edit-entry/edit-entry.ts b/src/addons/blog/pages/edit-entry/edit-entry.ts index 9a2d76dcf..8dca5c6c9 100644 --- a/src/addons/blog/pages/edit-entry/edit-entry.ts +++ b/src/addons/blog/pages/edit-entry/edit-entry.ts @@ -33,6 +33,7 @@ import { CoreEditorComponentsModule } from '@features/editor/components/componen import { CoreFileUploader } from '@features/fileuploader/services/fileuploader'; import { CoreTagComponentsModule } from '@features/tag/components/components.module'; import { CanLeave } from '@guards/can-leave'; +import { CoreLoadings } from '@services/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; @@ -267,7 +268,7 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit { return; } - const loading = await CoreDomUtils.showModalLoading('core.sending', true); + const loading = await CoreLoadings.show('core.sending', true); if (this.entry) { try { diff --git a/src/addons/blog/pages/index/index.ts b/src/addons/blog/pages/index/index.ts index 66d6650be..872477654 100644 --- a/src/addons/blog/pages/index/index.ts +++ b/src/addons/blog/pages/index/index.ts @@ -31,6 +31,7 @@ import { CoreArray } from '@singletons/array'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreTime } from '@singletons/time'; import { CorePopovers } from '@services/popovers'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays the list of blog entries. @@ -242,7 +243,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { * @param enabled If true, filter my entries. False otherwise. */ async onlyMyEntriesToggleChanged(enabled: boolean): Promise { - const loading = await CoreDomUtils.showModalLoading(); + const loading = await CoreLoadings.show(); try { this.filter.userid = !enabled ? undefined : this.currentUserId; @@ -307,7 +308,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { * @param id Entry id. */ async deleteEntry(id: number): Promise { - const loading = await CoreDomUtils.showModalLoading(); + const loading = await CoreLoadings.show(); try { await AddonBlog.deleteEntry({ entryid: id }); await this.refresh(); diff --git a/src/addons/calendar/pages/edit-event/edit-event.ts b/src/addons/calendar/pages/edit-event/edit-event.ts index 6e04bd418..daa805281 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.ts +++ b/src/addons/calendar/pages/edit-event/edit-event.ts @@ -47,6 +47,7 @@ import moment from 'moment-timezone'; import { ADDON_CALENDAR_COMPONENT } from '@addons/calendar/constants'; import { ContextLevel } from '@/core/constants'; import { CorePopovers } from '@services/popovers'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays a form to create/edit an event. @@ -407,7 +408,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await this.loadGroups(courseId); @@ -513,7 +514,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { } // Send the data. - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); let event: AddonCalendarEvent | AddonCalendarOfflineEventDBRecord; try { diff --git a/src/addons/calendar/pages/event/event.ts b/src/addons/calendar/pages/event/event.ts index 8986d2d74..67b82e7dc 100644 --- a/src/addons/calendar/pages/event/event.ts +++ b/src/addons/calendar/pages/event/event.ts @@ -44,6 +44,7 @@ import { CorePlatform } from '@services/platform'; import { CoreConfig } from '@services/config'; import { CoreToasts, ToastDuration } from '@services/toasts'; import { CorePopovers } from '@services/popovers'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays a single calendar event. @@ -418,7 +419,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { try { await CoreDomUtils.showDeleteConfirm(); - const modal = await CoreDomUtils.showModalLoading('core.deleting', true); + const modal = await CoreLoadings.show('core.deleting', true); try { await CoreReminders.removeReminder(id); @@ -525,12 +526,11 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { try { deleteAll = await CoreDomUtils.showConfirm(message, title, undefined, undefined, options); } catch { - // User canceled. return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { let onlineEventDeleted = false; @@ -587,7 +587,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { diff --git a/src/addons/coursecompletion/pages/report/report.ts b/src/addons/coursecompletion/pages/report/report.ts index 6449ec701..d481458cb 100644 --- a/src/addons/coursecompletion/pages/report/report.ts +++ b/src/addons/coursecompletion/pages/report/report.ts @@ -19,6 +19,7 @@ import { import { Component, OnInit } from '@angular/core'; import { CoreUser, CoreUserProfile } from '@features/user/services/user'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreLoadings } from '@services/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; @@ -123,7 +124,7 @@ export class AddonCourseCompletionReportPage implements OnInit { * Mark course as completed. */ async completeCourse(): Promise { - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonCourseCompletion.markCourseAsSelfCompleted(this.courseId); diff --git a/src/addons/enrol/guest/services/enrol-handler.ts b/src/addons/enrol/guest/services/enrol-handler.ts index cb5795dfb..712646143 100644 --- a/src/addons/enrol/guest/services/enrol-handler.ts +++ b/src/addons/enrol/guest/services/enrol-handler.ts @@ -22,7 +22,7 @@ import { import { makeSingleton } from '@singletons'; import { AddonEnrolGuest } from './guest'; import { CorePasswordModalResponse } from '@components/password-modal/password-modal'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreEnrol, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol'; import { CoreModals } from '@services/modals'; @@ -100,7 +100,7 @@ export class AddonEnrolGuestHandlerService implements CoreEnrolGuestHandler { } const validatePassword = async (password = ''): Promise => { - const modal = await CoreDomUtils.showModalLoading('core.loading', true); + const modal = await CoreLoadings.show('core.loading', true); try { const response = await AddonEnrolGuest.validateGuestAccessPassword(method.id, password); diff --git a/src/addons/enrol/self/services/enrol-handler.ts b/src/addons/enrol/self/services/enrol-handler.ts index c2838f53d..68a667bcd 100644 --- a/src/addons/enrol/self/services/enrol-handler.ts +++ b/src/addons/enrol/self/services/enrol-handler.ts @@ -21,6 +21,7 @@ import { CoreCoursesProvider } from '@features/courses/services/courses'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreEnrol, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Enrol handler. @@ -112,7 +113,7 @@ export class AddonEnrolSelfHandlerService implements CoreEnrolSelfHandler { */ protected async performEnrol(method: CoreEnrolEnrolmentMethod): Promise { const validatePassword = async (password = ''): Promise => { - const modal = await CoreDomUtils.showModalLoading('core.loading', true); + const modal = await CoreLoadings.show('core.loading', true); const response: CorePasswordModalResponse = { password, diff --git a/src/addons/messages/pages/discussion/discussion.ts b/src/addons/messages/pages/discussion/discussion.ts index 19b55f398..60784c767 100644 --- a/src/addons/messages/pages/discussion/discussion.ts +++ b/src/addons/messages/pages/discussion/discussion.ts @@ -48,6 +48,7 @@ import { CoreKeyboard } from '@singletons/keyboard'; import { CoreText } from '@singletons/text'; import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays a message discussion page. @@ -232,7 +233,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView protected async fetchData(): Promise { let loader: CoreIonLoadingElement | undefined; if (this.showLoadingModal) { - loader = await CoreDomUtils.showModalLoading(); + loader = await CoreLoadings.show(); } if (!this.groupMessagingEnabled && this.userId) { @@ -965,7 +966,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView options, ); - const modal = await CoreDomUtils.showModalLoading('core.deleting', true); + const modal = await CoreLoadings.show('core.deleting', true); try { await AddonMessages.deleteMessage(message, data && data[0]); @@ -1406,7 +1407,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView await CoreDomUtils.showConfirm(template, undefined, okText); this.blockIcon = CoreConstants.ICON_LOADING; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); this.showLoadingModal = true; try { @@ -1488,7 +1489,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.blockIcon = CoreConstants.ICON_LOADING; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); this.showLoadingModal = true; try { @@ -1527,7 +1528,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.addRemoveIcon = CoreConstants.ICON_LOADING; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); this.showLoadingModal = true; try { @@ -1558,7 +1559,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView throw new CoreError('No member selected to be confirmed.'); } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); this.showLoadingModal = true; try { @@ -1584,7 +1585,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView throw new CoreError('No member selected to be declined.'); } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); this.showLoadingModal = true; try { @@ -1618,7 +1619,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.addRemoveIcon = CoreConstants.ICON_LOADING; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); this.showLoadingModal = true; try { diff --git a/src/addons/messages/pages/settings/settings.ts b/src/addons/messages/pages/settings/settings.ts index 81387bc89..21a2e9886 100644 --- a/src/addons/messages/pages/settings/settings.ts +++ b/src/addons/messages/pages/settings/settings.ts @@ -28,6 +28,7 @@ import { CoreConstants } from '@/core/constants'; import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications'; import { CorePlatform } from '@services/platform'; import { CoreTextUtils } from '@services/utils/text'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays the messages settings page. @@ -155,7 +156,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); if (!this.advancedContactable) { // Convert from boolean to number. diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index cee76d906..e5a0c1d42 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -68,6 +68,7 @@ import { ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS, } from '../../constants'; import { CoreViewer } from '@features/viewer/services/viewer'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays an assignment submission. @@ -321,7 +322,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } const previousSubmission = this.previousAttempt.submission; - let modal = await CoreDomUtils.showModalLoading(); + let modal = await CoreLoadings.show(); const size = await CoreUtils.ignoreErrors( AddonModAssignHelper.getSubmissionSizeForCopy(this.assign, previousSubmission), @@ -339,7 +340,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } // User confirmed, copy the attempt. - modal = await CoreDomUtils.showModalLoading('core.sending', true); + modal = await CoreLoadings.show('core.sending', true); try { await AddonModAssignHelper.copyPreviousAttempt(this.assign, previousSubmission); @@ -898,7 +899,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can // Ask for confirmation. @todo plugin precheck_submission await CoreDomUtils.showConfirm(Translate.instant('addon.mod_assign.confirmsubmission')); - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonModAssign.submitForGrading( @@ -949,7 +950,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can throw new CoreError(Translate.instant('core.grades.badgrade')); } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); (this.gradeInfo?.outcomes || []).forEach((outcome) => { if (outcome.itemNumber && outcome.selectedId) { diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index 836927079..d11712cd6 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -46,6 +46,7 @@ import { ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT, } from '../../constants'; import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; /** * Page that allows adding or editing an assigment submission. @@ -314,7 +315,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { protected async hasDataChanged(): Promise { // Usually the hasSubmissionDataChanged call will be resolved inmediately, causing the modal to be shown just an instant. // We'll wait a bit before showing it to prevent this "blink". - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const data = this.getInputData(); @@ -397,7 +398,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { throw Translate.instant('addon.mod_assign.acceptsubmissionstatement'); } - let modal = await CoreDomUtils.showModalLoading(); + let modal = await CoreLoadings.show(); let size = -1; // Get size to ask for confirmation. @@ -414,7 +415,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { // Confirm action. await CoreFileUploaderHelper.confirmUploadFile(size, true, this.allowOffline); - modal = await CoreDomUtils.showModalLoading('core.sending', true); + modal = await CoreLoadings.show('core.sending', true); const pluginData = await this.prepareSubmissionData(inputData); if (!Object.keys(pluginData).length) { diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.ts b/src/addons/mod/bigbluebuttonbn/components/index/index.ts index b4f61d185..954fe5906 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.ts +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.ts @@ -32,6 +32,7 @@ import { AddonModBBBRecordingPlaybackTypes, } from '../../services/bigbluebuttonbn'; import { ADDON_MOD_BBB_COMPONENT } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays a Big Blue Button activity. @@ -295,7 +296,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo * @returns Promise resolved when done. */ async joinRoom(): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const joinUrl = await AddonModBBB.getJoinUrl(this.module.id, this.groupId); @@ -336,7 +337,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await AddonModBBB.endMeeting(this.bbb.id, this.groupId); diff --git a/src/addons/mod/chat/pages/chat/chat.ts b/src/addons/mod/chat/pages/chat/chat.ts index 4565e5c72..482c04526 100644 --- a/src/addons/mod/chat/pages/chat/chat.ts +++ b/src/addons/mod/chat/pages/chat/chat.ts @@ -32,6 +32,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays a chat session. @@ -342,7 +343,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { * @returns Promise resolved when done. */ async reconnect(): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Call startPolling would take a while for the first execution, so we'll execute it manually to check if it works now. diff --git a/src/addons/mod/chat/pages/sessions/sessions.ts b/src/addons/mod/chat/pages/sessions/sessions.ts index 10fb146b2..852504dc9 100644 --- a/src/addons/mod/chat/pages/sessions/sessions.ts +++ b/src/addons/mod/chat/pages/sessions/sessions.ts @@ -25,6 +25,7 @@ import { CoreTime } from '@singletons/time'; import { Translate } from '@singletons'; import { AddonModChat } from '@addons/mod/chat/services/chat'; import { CoreUtils } from '@services/utils/utils'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays list of chat sessions. @@ -126,7 +127,7 @@ export class AddonModChatSessionsPage implements OnInit, AfterViewInit, OnDestro * Reload chat sessions. */ async reloadSessions(): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await this.sessions.reload(); diff --git a/src/addons/mod/choice/components/index/index.ts b/src/addons/mod/choice/components/index/index.ts index a64944d79..764bb7750 100644 --- a/src/addons/mod/choice/components/index/index.ts +++ b/src/addons/mod/choice/components/index/index.ts @@ -41,6 +41,7 @@ import { ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS, AddonModChoiceShowResults, } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays a choice. @@ -383,7 +384,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo responses.push(this.selectedOption.id); } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { const online = await AddonModChoice.submitResponse(this.choice.id, this.choice.name, this.courseId, responses); @@ -421,7 +422,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonModChoice.deleteResponses(this.choice.id, this.choice.name, this.courseId); diff --git a/src/addons/mod/data/fields/latlong/component/latlong.ts b/src/addons/mod/data/fields/latlong/component/latlong.ts index 17c7a4f18..12365765a 100644 --- a/src/addons/mod/data/fields/latlong/component/latlong.ts +++ b/src/addons/mod/data/fields/latlong/component/latlong.ts @@ -19,6 +19,7 @@ import { FormBuilder } from '@angular/forms'; import { SafeUrl } from '@angular/platform-browser'; import { CoreAnyError } from '@classes/errors/error'; import { CoreGeolocation, CoreGeolocationError, CoreGeolocationErrorReason } from '@services/geolocation'; +import { CoreLoadings } from '@services/loadings'; import { CorePlatform } from '@services/platform'; import { CoreDomUtils } from '@services/utils/dom'; import { DomSanitizer } from '@singletons'; @@ -118,7 +119,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginBa async getLocation(event: Event): Promise { event.preventDefault(); - const modal = await CoreDomUtils.showModalLoading('addon.mod_data.gettinglocation', true); + const modal = await CoreLoadings.show('addon.mod_data.gettinglocation', true); try { const coordinates = await CoreGeolocation.getCoordinates(); diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index 1c1f43cf0..5940aa0b2 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -44,6 +44,7 @@ import { CoreTextUtils } from '@services/utils/text'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED, AddonModDataTemplateType } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays the view edit page. @@ -285,7 +286,7 @@ export class AddonModDataEditPage implements OnInit { throw new CoreError(Translate.instant('addon.mod_data.emptyaddform')); } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); // Create an ID to assign files. const entryTemp = this.entryId ? this.entryId : - (Date.now()); diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts index faaeeb5f9..10dad51bc 100644 --- a/src/addons/mod/data/services/data-helper.ts +++ b/src/addons/mod/data/services/data-helper.ts @@ -48,6 +48,7 @@ import { AddonModDataTemplateMode, } from '../constants'; import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; /** * Service that provides helper functions for datas. @@ -154,7 +155,7 @@ export class AddonModDataHelperProvider { ): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { courseId = await this.getActivityCourseIdIfNotSet(dataId, courseId, siteId); @@ -857,7 +858,7 @@ export class AddonModDataHelperProvider { try { await CoreDomUtils.showDeleteConfirm('addon.mod_data.confirmdeleterecord'); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { if (entryId > 0) { diff --git a/src/addons/mod/data/services/handlers/edit-link-lazy.ts b/src/addons/mod/data/services/handlers/edit-link-lazy.ts index b5b8c2894..d76c88685 100644 --- a/src/addons/mod/data/services/handlers/edit-link-lazy.ts +++ b/src/addons/mod/data/services/handlers/edit-link-lazy.ts @@ -17,7 +17,7 @@ import { Params } from '@angular/router'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_DATA_FEATURE_NAME, ADDON_MOD_DATA_PAGE_NAME } from '../../constants'; import { AddonModDataEditLinkHandlerService } from '@addons/mod/data/services/handlers/edit-link'; @@ -37,7 +37,7 @@ export class AddonModDataEditLinkHandlerLazyService extends AddonModDataEditLink * @inheritdoc */ async handleAction(siteId: string, params: Record): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const dataId = parseInt(params.d, 10); const rId = params.rid || ''; diff --git a/src/addons/mod/data/services/handlers/show-link-lazy.ts b/src/addons/mod/data/services/handlers/show-link-lazy.ts index 652ba7f3a..3b6e441be 100644 --- a/src/addons/mod/data/services/handlers/show-link-lazy.ts +++ b/src/addons/mod/data/services/handlers/show-link-lazy.ts @@ -17,7 +17,7 @@ import { Params } from '@angular/router'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_DATA_PAGE_NAME } from '../../constants'; import { AddonModDataShowLinkHandlerService } from '@addons/mod/data/services/handlers/show-link'; @@ -33,7 +33,7 @@ export class AddonModDataShowLinkHandlerLazyService extends AddonModDataShowLink * @inheritdoc */ async handleAction(siteId: string, params: Record): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const dataId = parseInt(params.d, 10); const rId = params.rid || ''; const group = parseInt(params.group, 10) || false; diff --git a/src/addons/mod/feedback/pages/form/form.ts b/src/addons/mod/feedback/pages/form/form.ts index 0f482f555..0a47824fe 100644 --- a/src/addons/mod/feedback/pages/form/form.ts +++ b/src/addons/mod/feedback/pages/form/form.ts @@ -37,6 +37,7 @@ import { AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services import { AddonModFeedbackSync } from '../../services/feedback-sync'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_FORM_SUBMITTED, ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays feedback form. @@ -423,7 +424,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { return CoreNavigator.back(); } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await CoreSites.visitLink(this.siteAfterSubmit, { siteId: this.currentSite.id }); diff --git a/src/addons/mod/feedback/services/feedback-helper.ts b/src/addons/mod/feedback/services/feedback-helper.ts index d1cccc4f6..b474ea4a6 100644 --- a/src/addons/mod/feedback/services/feedback-helper.ts +++ b/src/addons/mod/feedback/services/feedback-helper.ts @@ -40,6 +40,7 @@ import { ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT, ADDON_MOD_FEEDBACK_PAGE_NAME, } from '../constants'; +import { CoreLoadings } from '@services/loadings'; const MODE_RESPONSETIME = 1; const MODE_COURSE = 2; @@ -179,7 +180,7 @@ export class AddonModFeedbackHelperProvider { async handleShowEntriesLink(params: Record, siteId?: string): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const module = await CoreCourse.getModuleBasicInfo( diff --git a/src/addons/mod/feedback/services/handlers/analysis-link.ts b/src/addons/mod/feedback/services/handlers/analysis-link.ts index 6ad0dce15..5fb6de0ee 100644 --- a/src/addons/mod/feedback/services/handlers/analysis-link.ts +++ b/src/addons/mod/feedback/services/handlers/analysis-link.ts @@ -20,6 +20,7 @@ import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Content links handler for a feedback analysis. @@ -38,7 +39,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks getActions(siteIds: string[], url: string, params: Record): CoreContentLinksAction[] { return [{ action: async (siteId: string) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const moduleId = Number(params.id); diff --git a/src/addons/mod/feedback/services/handlers/complete-link.ts b/src/addons/mod/feedback/services/handlers/complete-link.ts index 2a3d6caab..38120de01 100644 --- a/src/addons/mod/feedback/services/handlers/complete-link.ts +++ b/src/addons/mod/feedback/services/handlers/complete-link.ts @@ -21,6 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Content links handler for feedback complete questions. @@ -39,7 +40,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks getActions(siteIds: string[], url: string, params: Record): CoreContentLinksAction[] { return [{ action: async (siteId: string) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const moduleId = Number(params.id); diff --git a/src/addons/mod/feedback/services/handlers/print-link.ts b/src/addons/mod/feedback/services/handlers/print-link.ts index abbb8d575..5104e8465 100644 --- a/src/addons/mod/feedback/services/handlers/print-link.ts +++ b/src/addons/mod/feedback/services/handlers/print-link.ts @@ -21,6 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Content links handler for feedback print questions. @@ -39,7 +40,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan getActions(siteIds: string[], url: string, params: Record): CoreContentLinksAction[] { return [{ action: async (siteId: string) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const moduleId = Number(params.id); diff --git a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts index 7ef4fdc21..603947ba7 100644 --- a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts +++ b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts @@ -21,6 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Content links handler for feedback show non respondents. * Match mod/feedback/show_nonrespondents.php with a valid feedback id. @@ -38,7 +39,7 @@ export class AddonModFeedbackShowNonRespondentsLinkHandlerService extends CoreCo getActions(siteIds: string[], url: string, params: Record): CoreContentLinksAction[] { return [{ action: async (siteId: string) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const moduleId = Number(params.id); diff --git a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts index 3169f0d01..d974562cb 100644 --- a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts +++ b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts @@ -21,6 +21,7 @@ import { AddonModForum, AddonModForumDiscussion } from '../../services/forum'; import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT } from '../../constants'; import { CoreToasts } from '@services/toasts'; import { CoreSharedModule } from '@/core/shared.module'; +import { CoreLoadings } from '@services/loadings'; /** * This component is meant to display a popover with the discussion options. @@ -67,7 +68,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { * @param locked True to lock the discussion, false to unlock. */ async setLockState(locked: boolean): Promise { - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { const response = await AddonModForum.setLockState(this.forumId, this.discussion.discussion, locked); @@ -98,7 +99,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { * @param pinned True to pin the discussion, false to unpin it. */ async setPinState(pinned: boolean): Promise { - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonModForum.setPinState(this.discussion.discussion, pinned); @@ -130,7 +131,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { * @param starred True to star the discussion, false to unstar it. */ async toggleFavouriteState(starred: boolean): Promise { - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonModForum.toggleFavouriteState(this.discussion.discussion, starred); diff --git a/src/addons/mod/forum/components/index/index.ts b/src/addons/mod/forum/components/index/index.ts index dfb74e812..f9d91c658 100644 --- a/src/addons/mod/forum/components/index/index.ts +++ b/src/addons/mod/forum/components/index/index.ts @@ -66,6 +66,7 @@ import { import { CoreSearchGlobalSearch } from '@features/search/services/global-search'; import { CoreToasts } from '@services/toasts'; import { CorePopovers } from '@services/popovers'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays a forum entry page. */ @@ -669,7 +670,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom * Group has changed. */ async groupChanged(): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await Promise.all([ diff --git a/src/addons/mod/forum/components/post/post.ts b/src/addons/mod/forum/components/post/post.ts index 89d894152..0f2028c1b 100644 --- a/src/addons/mod/forum/components/post/post.ts +++ b/src/addons/mod/forum/components/post/post.ts @@ -55,6 +55,7 @@ import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, ADDON_MOD_FORUM_COMPONENT } fr import { CoreToasts } from '@services/toasts'; import { toBoolean } from '@/core/transforms/boolean'; import { CorePopovers } from '@services/popovers'; +import { CoreLoadings } from '@services/loadings'; /** * Components that shows a discussion post, its attachments and the action buttons allowed (reply, etc.). @@ -150,7 +151,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges try { await CoreDomUtils.showDeleteConfirm('addon.mod_forum.deletesure'); - const modal = await CoreDomUtils.showModalLoading('core.deleting', true); + const modal = await CoreLoadings.show('core.deleting', true); try { const response = await AddonModForum.deletePost(this.post.id); @@ -366,7 +367,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges const replyingTo = this.formData.replyingTo!; const files = this.formData.files || []; const isEditOnline = this.formData.id && this.formData.id > 0; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); // Add some HTML to the message if needed. message = CoreTextUtils.formatHtmlLines(message); diff --git a/src/addons/mod/forum/pages/discussion/discussion.ts b/src/addons/mod/forum/pages/discussion/discussion.ts index ea1d5b137..ef8fc7ec9 100644 --- a/src/addons/mod/forum/pages/discussion/discussion.ts +++ b/src/addons/mod/forum/pages/discussion/discussion.ts @@ -60,6 +60,7 @@ import { } from '../../constants'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreToasts } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; type SortType = 'flat-newest' | 'flat-oldest' | 'nested'; @@ -717,7 +718,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { const response = await AddonModForum.setLockState(this.forumId, this.discussionId, locked); @@ -752,7 +753,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonModForum.setPinState(this.discussionId, pinned); @@ -788,7 +789,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonModForum.toggleFavouriteState(this.discussionId, starred); diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts index 7c798803a..963083e3c 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts @@ -52,6 +52,7 @@ import { ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT, } from '../../constants'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; +import { CoreLoadings } from '@services/loadings'; type NewDiscussionData = { subject: string; @@ -549,7 +550,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); // Add some HTML to the message if needed. message = CoreTextUtils.formatHtmlLines(message); diff --git a/src/addons/mod/forum/services/handlers/post-link.ts b/src/addons/mod/forum/services/handlers/post-link.ts index c972ff703..046731b9e 100644 --- a/src/addons/mod/forum/services/handlers/post-link.ts +++ b/src/addons/mod/forum/services/handlers/post-link.ts @@ -18,7 +18,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants'; @@ -43,7 +43,7 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler ): CoreContentLinksAction[] | Promise { return [{ action: async (siteId): Promise => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const forumId = parseInt(params.forum, 10); try { diff --git a/src/addons/mod/glossary/pages/edit/edit.ts b/src/addons/mod/glossary/pages/edit/edit.ts index edd81fd92..e178775f1 100644 --- a/src/addons/mod/glossary/pages/edit/edit.ts +++ b/src/addons/mod/glossary/pages/edit/edit.ts @@ -40,6 +40,7 @@ import { AddonModGlossaryHelper } from '../../services/glossary-helper'; import { AddonModGlossaryOffline } from '../../services/glossary-offline'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_GLOSSARY_COMPONENT } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays the edit form. @@ -211,7 +212,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { const savedOnline = await this.handler.save(this.glossary); diff --git a/src/addons/mod/glossary/pages/entry/entry.ts b/src/addons/mod/glossary/pages/entry/entry.ts index 19e5637ce..1286b4e00 100644 --- a/src/addons/mod/glossary/pages/entry/entry.ts +++ b/src/addons/mod/glossary/pages/entry/entry.ts @@ -41,6 +41,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_ENTRY_UPDATED, ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays a glossary entry. @@ -191,7 +192,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { if (this.onlineEntry) { diff --git a/src/addons/mod/glossary/services/handlers/edit-link.ts b/src/addons/mod/glossary/services/handlers/edit-link.ts index 56a4c54f8..bd6f8e908 100644 --- a/src/addons/mod/glossary/services/handlers/edit-link.ts +++ b/src/addons/mod/glossary/services/handlers/edit-link.ts @@ -21,6 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Content links handler for glossary new entry. @@ -40,7 +41,7 @@ export class AddonModGlossaryEditLinkHandlerService extends CoreContentLinksHand getActions(siteIds: string[], url: string, params: Record): CoreContentLinksAction[] { return [{ action: async (siteId: string) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const cmId = Number(params.cmid); diff --git a/src/addons/mod/glossary/services/handlers/entry-link.ts b/src/addons/mod/glossary/services/handlers/entry-link.ts index 742056478..f890b2b73 100644 --- a/src/addons/mod/glossary/services/handlers/entry-link.ts +++ b/src/addons/mod/glossary/services/handlers/entry-link.ts @@ -22,6 +22,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { AddonModGlossary } from '../glossary'; import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Handler to treat links to glossary entries. @@ -39,7 +40,7 @@ export class AddonModGlossaryEntryLinkHandlerService extends CoreContentLinksHan getActions(siteIds: string[], url: string, params: Record): CoreContentLinksAction[] { return [{ action: async (siteId: string) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const entryId = params.mode == 'entry' ? Number(params.hook) : Number(params.eid); diff --git a/src/addons/mod/h5pactivity/services/handlers/report-link.ts b/src/addons/mod/h5pactivity/services/handlers/report-link.ts index c92418b90..8c2ee7aed 100644 --- a/src/addons/mod/h5pactivity/services/handlers/report-link.ts +++ b/src/addons/mod/h5pactivity/services/handlers/report-link.ts @@ -24,6 +24,7 @@ import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; import { AddonModH5PActivity } from '../h5pactivity'; import { ADDON_MOD_H5PACTIVITY_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Handler to treat links to H5P activity report. @@ -45,7 +46,7 @@ export class AddonModH5PActivityReportLinkHandlerService extends CoreContentLink ): CoreContentLinksAction[] | Promise { return [{ action: async (siteId) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const instanceId = Number(params.a); diff --git a/src/addons/mod/lesson/services/handlers/grade-link.ts b/src/addons/mod/lesson/services/handlers/grade-link.ts index 97dc7ab9d..de59e4418 100644 --- a/src/addons/mod/lesson/services/handlers/grade-link.ts +++ b/src/addons/mod/lesson/services/handlers/grade-link.ts @@ -23,6 +23,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { AddonModLesson } from '../lesson'; import { ADDON_MOD_LESSON_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Handler to treat links to lesson grade. @@ -55,7 +56,7 @@ export class AddonModLessonGradeLinkHandlerService extends CoreContentLinksModul const moduleId = Number(params.id); const userId = Number(params.userid) || 0; - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const module = await CoreCourse.getModuleBasicInfo( diff --git a/src/addons/mod/lesson/services/handlers/index-link.ts b/src/addons/mod/lesson/services/handlers/index-link.ts index 96670924d..39fd3d9c3 100644 --- a/src/addons/mod/lesson/services/handlers/index-link.ts +++ b/src/addons/mod/lesson/services/handlers/index-link.ts @@ -19,7 +19,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; import { AddonModLesson } from '../lesson'; @@ -85,7 +85,7 @@ export class AddonModLessonIndexLinkHandlerService extends CoreContentLinksModul password: string, siteId: string, ): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Get the module. diff --git a/src/addons/mod/lesson/services/handlers/report-link.ts b/src/addons/mod/lesson/services/handlers/report-link.ts index de1955316..e22aab6c7 100644 --- a/src/addons/mod/lesson/services/handlers/report-link.ts +++ b/src/addons/mod/lesson/services/handlers/report-link.ts @@ -22,6 +22,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_LESSON_PAGE_NAME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Handler to treat links to lesson report. @@ -86,7 +87,7 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand */ protected async openReportOverview(moduleId: number, groupId?: number, siteId?: string): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Get the module object. @@ -132,7 +133,7 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand siteId: string, ): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Get the module object. diff --git a/src/addons/mod/lti/services/lti-helper.ts b/src/addons/mod/lti/services/lti-helper.ts index b6d410377..66fe7d200 100644 --- a/src/addons/mod/lti/services/lti-helper.ts +++ b/src/addons/mod/lti/services/lti-helper.ts @@ -23,6 +23,7 @@ import { makeSingleton } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { AddonModLti, AddonModLtiLti } from './lti'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreLoadings } from '@services/loadings'; /** * Service that provides some helper functions for LTI. @@ -62,7 +63,7 @@ export class AddonModLtiHelperProvider { async getDataAndLaunch(courseId: number, module: CoreCourseModuleData, lti?: AddonModLtiLti, siteId?: string): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const openInBrowser = await AddonModLti.shouldLaunchInBrowser(siteId); diff --git a/src/addons/mod/quiz/pages/player/player.ts b/src/addons/mod/quiz/pages/player/player.ts index 997fd63e4..991b39b68 100644 --- a/src/addons/mod/quiz/pages/player/player.ts +++ b/src/addons/mod/quiz/pages/player/player.ts @@ -55,6 +55,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT, AddonModQuizAttemptStates, ADDON_MOD_QUIZ_COMPONENT } from '../../constants'; import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Page that allows attempting a quiz. @@ -166,7 +167,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { } // Save answers. - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await this.processAttempt(false, false); @@ -217,7 +218,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { // Confirm that the user really wants to do it. await CoreDomUtils.showConfirm(Translate.instant('core.areyousure')); - modal = await CoreDomUtils.showModalLoading('core.sending', true); + modal = await CoreLoadings.show('core.sending', true); // Get the answers. const answers = await this.prepareAnswers(this.quiz.coursemodule); @@ -292,7 +293,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { // First try to save the attempt data. We only save it if we're not seeing the summary. if (!this.showSummary) { - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await this.processAttempt(false, false); @@ -440,7 +441,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { ); } - modal = await CoreDomUtils.showModalLoading('core.sending', true); + modal = await CoreLoadings.show('core.sending', true); await this.processAttempt(userFinish, timeUp); @@ -719,7 +720,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { if (this.reloadNavigation) { // Some data has changed, reload the navigation. - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); await CoreUtils.ignoreErrors(this.loadNavigation()); diff --git a/src/addons/mod/quiz/services/quiz-helper.ts b/src/addons/mod/quiz/services/quiz-helper.ts index 24f2e6337..4026938fb 100644 --- a/src/addons/mod/quiz/services/quiz-helper.ts +++ b/src/addons/mod/quiz/services/quiz-helper.ts @@ -41,6 +41,7 @@ import { QuestionDisplayOptionsMarks } from '@features/question/constants'; import { CoreGroups } from '@services/groups'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Helper service that provides some features for quiz. @@ -335,7 +336,7 @@ export class AddonModQuizHelperProvider { async handleReviewLink(attemptId: number, page?: number, quizId?: number, siteId?: string): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { if (!quizId) { diff --git a/src/addons/mod/resource/services/resource-helper.ts b/src/addons/mod/resource/services/resource-helper.ts index 539616973..66afb0a74 100644 --- a/src/addons/mod/resource/services/resource-helper.ts +++ b/src/addons/mod/resource/services/resource-helper.ts @@ -32,6 +32,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreTextUtils } from '@services/utils/text'; import { CoreTimeUtils } from '@services/utils/time'; import { ADDON_MOD_RESOURCE_COMPONENT } from '../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Service that provides helper functions for resources. @@ -190,7 +191,7 @@ export class AddonModResourceHelperProvider { * @returns Resolved when done. */ async openModuleFile(module: CoreCourseModuleData, courseId: number, options: CoreUtilsOpenFileOptions = {}): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Download and open the file from the resource contents. diff --git a/src/addons/mod/survey/components/index/index.ts b/src/addons/mod/survey/components/index/index.ts index 0d8a4b583..c1adf5b53 100644 --- a/src/addons/mod/survey/components/index/index.ts +++ b/src/addons/mod/survey/components/index/index.ts @@ -38,6 +38,7 @@ import { } from '../../services/survey-sync'; import { CoreUtils } from '@services/utils/utils'; import { ADDON_MOD_SURVEY_AUTO_SYNCED, ADDON_MOD_SURVEY_COMPONENT } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays a survey. @@ -197,7 +198,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo await CoreDomUtils.showConfirm(Translate.instant('core.areyousure')); const answers: AddonModSurveySubmitAnswerData[] = []; - modal = await CoreDomUtils.showModalLoading('core.sending', true); + modal = await CoreLoadings.show('core.sending', true); for (const x in this.answers) { answers.push({ diff --git a/src/addons/mod/url/services/handlers/module.ts b/src/addons/mod/url/services/handlers/module.ts index cf4f0eae0..1b35ed386 100644 --- a/src/addons/mod/url/services/handlers/module.ts +++ b/src/addons/mod/url/services/handlers/module.ts @@ -20,7 +20,7 @@ import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/servic import { CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate'; import { CoreNavigationOptions } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; import { AddonModUrl } from '../url'; @@ -82,7 +82,7 @@ export class AddonModUrlModuleHandlerService extends CoreModuleHandlerBase imple class: 'addon-mod_url-handler', showDownloadButton: false, action: async (event: Event, module: CoreCourseModuleData, courseId: number, options?: CoreNavigationOptions) => { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const shouldOpen = await this.shouldOpenLink(module); diff --git a/src/addons/mod/url/services/url-helper.ts b/src/addons/mod/url/services/url-helper.ts index da2d65d3b..e379b7269 100644 --- a/src/addons/mod/url/services/url-helper.ts +++ b/src/addons/mod/url/services/url-helper.ts @@ -13,8 +13,8 @@ // limitations under the License. import { Injectable } from '@angular/core'; +import { CoreLoadings } from '@services/loadings'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; /** @@ -29,7 +29,7 @@ export class AddonModUrlHelperProvider { * @param url The URL to go to. */ async open(url: string): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await CoreSites.visitLink(url, { diff --git a/src/addons/mod/wiki/pages/edit/edit.ts b/src/addons/mod/wiki/pages/edit/edit.ts index 0e8795775..e6a7ca15a 100644 --- a/src/addons/mod/wiki/pages/edit/edit.ts +++ b/src/addons/mod/wiki/pages/edit/edit.ts @@ -32,6 +32,7 @@ import { AddonModWikiOffline } from '../../services/wiki-offline'; import { AddonModWikiSync } from '../../services/wiki-sync'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_PAGE_CREATED_EVENT, ADDON_MOD_WIKI_RENEW_LOCK_TIME } from '../../constants'; +import { CoreLoadings } from '@services/loadings'; /** * Page that allows adding or editing a wiki page. @@ -362,7 +363,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave { const title = values.title; let text = values.text ?? ''; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); text = CoreTextUtils.restorePluginfileUrls(text, this.subwikiFiles); text = CoreTextUtils.formatHtmlLines(text); diff --git a/src/addons/mod/wiki/services/handlers/create-link-lazy.ts b/src/addons/mod/wiki/services/handlers/create-link-lazy.ts index 0976c03fe..977b10968 100644 --- a/src/addons/mod/wiki/services/handlers/create-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/create-link-lazy.ts @@ -22,6 +22,7 @@ import { makeSingleton } from '@singletons'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiCreateLinkHandlerService } from '@addons/mod/wiki/services/handlers/create-link'; +import { CoreLoadings } from '@services/loadings'; /** * Handler to treat links to create a wiki page. @@ -84,7 +85,7 @@ export class AddonModWikiCreateLinkHandlerLazyService extends AddonModWikiCreate * @inheritdoc */ async handleAction(siteId: string, courseId: number, params: Record): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const { AddonModWikiIndexPage } = await import('../../pages/index'); try { diff --git a/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts b/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts index f6e483ba6..0bdc5b3df 100644 --- a/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts @@ -21,6 +21,7 @@ import { makeSingleton } from '@singletons'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiEditLinkHandlerService } from '@addons/mod/wiki/services/handlers/edit-link'; +import { CoreLoadings } from '@services/loadings'; /** * Handler to treat links to edit a wiki page. @@ -32,7 +33,7 @@ export class AddonModWikiEditLinkHandlerLazyService extends AddonModWikiEditLink * @inheritdoc */ async handleAction(siteId: string, params: Record): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const pageId = Number(params.pageid); diff --git a/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts b/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts index d82efeab0..d8db96fcb 100644 --- a/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts @@ -22,6 +22,7 @@ import { Md5 } from 'ts-md5'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiPageOrMapLinkHandlerService } from '@addons/mod/wiki/services/handlers/page-or-map-link'; +import { CoreLoadings } from '@services/loadings'; /** * Handler to treat links to a wiki page or the wiki map. @@ -33,7 +34,7 @@ export class AddonModWikiPageOrMapLinkHandlerLazyService extends AddonModWikiPag * @inheritdoc */ async handleAction(url: string, siteId: string, params: Record): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const pageId = parseInt(params.pageid, 10); const action = url.indexOf('mod/wiki/map.php') != -1 ? 'map' : 'page'; diff --git a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts index 1c1908047..9f8344d89 100644 --- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts +++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts @@ -43,6 +43,7 @@ import { AddonModWorkshopOverallFeedbackMode, } from '@addons/mod/workshop/constants'; import { toBoolean } from '@/core/transforms/boolean'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays workshop assessment strategy form. @@ -302,7 +303,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe let saveOffline = false; let allowOffline = !files.length; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); this.data.fieldErrors = {}; diff --git a/src/addons/mod/workshop/components/assessment/assessment.ts b/src/addons/mod/workshop/components/assessment/assessment.ts index 6fac33bd2..9be8235fd 100644 --- a/src/addons/mod/workshop/components/assessment/assessment.ts +++ b/src/addons/mod/workshop/components/assessment/assessment.ts @@ -26,6 +26,7 @@ import { AddonModWorkshopSubmissionDataWithOfflineData, } from '../../services/workshop-helper'; import { AddonModWorkshopOffline } from '../../services/workshop-offline'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays workshop assessment. @@ -123,7 +124,7 @@ export class AddonModWorkshopAssessmentComponent implements OnInit { }; if (!this.submission) { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { params.submission = await AddonModWorkshopHelper.getSubmissionById( diff --git a/src/addons/mod/workshop/pages/assessment/assessment.ts b/src/addons/mod/workshop/pages/assessment/assessment.ts index 080ac4155..eb1601a86 100644 --- a/src/addons/mod/workshop/pages/assessment/assessment.ts +++ b/src/addons/mod/workshop/pages/assessment/assessment.ts @@ -44,6 +44,7 @@ import { ADDON_MOD_WORKSHOP_COMPONENT, AddonModWorkshopPhase, } from '@addons/mod/workshop/constants'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays a workshop assessment. @@ -372,7 +373,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea * @returns Resolved when done. */ protected async sendEvaluation(): Promise { - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); const inputData: AddonModWorkshopAssessmentEvaluation = this.evaluateForm.value; const grade = inputData.grade >= 0 ? String(inputData.grade) : ''; diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts index 26a5a40b7..27ebfea2e 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts @@ -44,6 +44,7 @@ import { AddonModWorkshopAction, AddonModWorkshopSubmissionType, } from '@addons/mod/workshop/constants'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays the workshop edit submission. @@ -353,7 +354,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca let saveOffline = false; - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); const submissionId = this.submission?.id; // Add some HTML to the message if needed. diff --git a/src/addons/mod/workshop/pages/submission/submission.ts b/src/addons/mod/workshop/pages/submission/submission.ts index ba743b49b..295fc7903 100644 --- a/src/addons/mod/workshop/pages/submission/submission.ts +++ b/src/addons/mod/workshop/pages/submission/submission.ts @@ -55,6 +55,7 @@ import { AddonModWorkshopAction, AddonModWorkshopPhase, } from '@addons/mod/workshop/constants'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays a workshop submission. @@ -510,7 +511,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea * @returns Resolved when done. */ protected async sendEvaluation(): Promise { - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); const inputData: { grade: number | string; @@ -559,7 +560,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea return; } - const modal = await CoreDomUtils.showModalLoading('core.deleting', true); + const modal = await CoreLoadings.show('core.deleting', true); let success = false; try { diff --git a/src/addons/notes/components/add/add-modal.ts b/src/addons/notes/components/add/add-modal.ts index c4c12b786..be4d547e8 100644 --- a/src/addons/notes/components/add/add-modal.ts +++ b/src/addons/notes/components/add/add-modal.ts @@ -21,6 +21,7 @@ import { ModalController } from '@singletons'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays a text area for composing a note. @@ -52,7 +53,7 @@ export class AddonNotesAddComponent { e.stopPropagation(); CoreKeyboard.close(); - const loadingModal = await CoreDomUtils.showModalLoading('core.sending', true); + const loadingModal = await CoreLoadings.show('core.sending', true); // Freeze the add note button. this.processing = true; diff --git a/src/addons/notifications/pages/settings/settings.ts b/src/addons/notifications/pages/settings/settings.ts index be282aa1a..6be1b7032 100644 --- a/src/addons/notifications/pages/settings/settings.ts +++ b/src/addons/notifications/pages/settings/settings.ts @@ -40,6 +40,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CoreTextUtils } from '@services/utils/text'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays notifications settings. @@ -311,7 +312,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { CoreUser.updateUserPreferences([], !enable); diff --git a/src/addons/privatefiles/services/privatefiles-helper.ts b/src/addons/privatefiles/services/privatefiles-helper.ts index b12cd780a..c5d14ae9a 100644 --- a/src/addons/privatefiles/services/privatefiles-helper.ts +++ b/src/addons/privatefiles/services/privatefiles-helper.ts @@ -15,7 +15,7 @@ import { Injectable } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; import { AddonPrivateFiles, AddonPrivateFilesGetUserInfoWSResult } from './privatefiles'; import { CoreError } from '@classes/errors/error'; @@ -60,7 +60,7 @@ export class AddonPrivateFilesHelperProvider { } // File uploaded. Move it to private files. - const modal = await CoreDomUtils.showModalLoading('core.fileuploader.uploading', true); + const modal = await CoreLoadings.show('core.fileuploader.uploading', true); try { await AddonPrivateFiles.moveFromDraftToPrivate(result.itemid); diff --git a/src/addons/report/insights/services/handlers/action-link.ts b/src/addons/report/insights/services/handlers/action-link.ts index 679ae22d6..5bbc98433 100644 --- a/src/addons/report/insights/services/handlers/action-link.ts +++ b/src/addons/report/insights/services/handlers/action-link.ts @@ -21,6 +21,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton, Translate } from '@singletons'; import { AddonReportInsights } from '../insights'; import { CoreToasts } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; // Bulk actions supported, along with the related lang string. const BULK_ACTIONS = { @@ -51,7 +52,7 @@ export class AddonReportInsightsActionLinkHandlerService extends CoreContentLink return [{ action: async (siteId?: string): Promise => { // Send the action. - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await AddonReportInsights.sendActionExecuted(params.action, [Number(params.predictionid)], siteId); diff --git a/src/addons/storagemanager/pages/course-storage/course-storage.ts b/src/addons/storagemanager/pages/course-storage/course-storage.ts index acf17dfb2..6573b2cb0 100644 --- a/src/addons/storagemanager/pages/course-storage/course-storage.ts +++ b/src/addons/storagemanager/pages/course-storage/course-storage.ts @@ -26,6 +26,7 @@ import { CoreCourseModulePrefetchHandler } from '@features/course/services/module-prefetch-delegate'; import { CoreCourseAnyCourseData, CoreCourses } from '@features/courses/services/courses'; import { AccordionGroupChangeEventDetail, IonAccordionGroup } from '@ionic/angular'; +import { CoreLoadings } from '@services/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; @@ -469,7 +470,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { * @returns Promise Once deleting has finished */ protected async deleteModules(modules: AddonStorageManagerModule[], section?: AddonStorageManagerCourseSection): Promise { - const modal = await CoreDomUtils.showModalLoading('core.deleting', true); + const modal = await CoreLoadings.show('core.deleting', true); const promises: Promise[] = []; modules.forEach((module) => { diff --git a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts index ea4340c56..6e44a0c85 100644 --- a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts +++ b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts @@ -21,6 +21,7 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; import { CoreSettingsHelper, CoreSiteSpaceUsage } from '@features/settings/services/settings-helper'; import { CoreSiteHome } from '@features/sitehome/services/sitehome'; +import { CoreLoadings } from '@services/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; @@ -121,7 +122,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy return; } - const modal = await CoreDomUtils.showModalLoading('core.deleting', true); + const modal = await CoreLoadings.show('core.deleting', true); const deletedCourseIds = this.completelyDownloadedCourses.map((course) => course.id); try { @@ -160,7 +161,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy return; } - const modal = await CoreDomUtils.showModalLoading('core.deleting', true); + const modal = await CoreLoadings.show('core.deleting', true); try { await CoreCourseHelper.deleteCourseFiles(course.id); diff --git a/src/core/classes/sites/site.ts b/src/core/classes/sites/site.ts index f0bd5fe73..5cd6d6d5d 100644 --- a/src/core/classes/sites/site.ts +++ b/src/core/classes/sites/site.ts @@ -55,6 +55,7 @@ import { CoreSiteInfo } from './unauthenticated-site'; import { CoreAuthenticatedSite, CoreAuthenticatedSiteOptionalData, CoreSiteWSPreSets, WSObservable } from './authenticated-site'; import { firstValueFrom } from 'rxjs'; import { CorePlatform } from '@services/platform'; +import { CoreLoadings } from '@services/loadings'; /** * Class that represents a site (combination of site + user). @@ -703,7 +704,7 @@ export class CoreSite extends CoreAuthenticatedSite { let modal: CoreIonLoadingElement | undefined; if (showModal) { - modal = await CoreDomUtils.showModalLoading(); + modal = await CoreLoadings.show(); } try { diff --git a/src/core/components/local-file/local-file.ts b/src/core/components/local-file/local-file.ts index 0c4b12949..2c9c70e97 100644 --- a/src/core/components/local-file/local-file.ts +++ b/src/core/components/local-file/local-file.ts @@ -28,6 +28,7 @@ import { CoreForms } from '@singletons/form'; import { CorePath } from '@singletons/path'; import { CorePlatform } from '@services/platform'; import { toBoolean } from '@/core/transforms/boolean'; +import { CoreLoadings } from '@services/loadings'; /** * Component to handle a local file. Only files inside the app folder can be managed. @@ -180,7 +181,7 @@ export class CoreLocalFileComponent implements OnInit { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const fileAndDir = CoreFile.getFileAndDirectoryFromPath(this.relativePath); const newPath = CorePath.concatenatePaths(fileAndDir.directory, newName); @@ -224,7 +225,7 @@ export class CoreLocalFileComponent implements OnInit { // Ask confirmation. await CoreDomUtils.showDeleteConfirm('core.confirmdeletefile'); - modal = await CoreDomUtils.showModalLoading('core.deleting', true); + modal = await CoreLoadings.show('core.deleting', true); await CoreFile.removeFile(this.relativePath); diff --git a/src/core/components/password-modal/password-modal.ts b/src/core/components/password-modal/password-modal.ts index 60a19efa0..519a707cb 100644 --- a/src/core/components/password-modal/password-modal.ts +++ b/src/core/components/password-modal/password-modal.ts @@ -17,7 +17,7 @@ import { Component, ViewChild, ElementRef, Input } from '@angular/core'; import { CoreSites } from '@services/sites'; import { CoreForms } from '@singletons/form'; import { ModalController } from '@singletons'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; /** * Modal that asks the password. @@ -82,7 +82,7 @@ export class CorePasswordModalComponent { return response; } - const modal = await CoreDomUtils.showModalLoading('core.loading', true); + const modal = await CoreLoadings.show('core.loading', true); try { return await this.validator(password); } catch (error) { diff --git a/src/core/core.module.ts b/src/core/core.module.ts index 28ba4326b..234a8f7c3 100644 --- a/src/core/core.module.ts +++ b/src/core/core.module.ts @@ -59,6 +59,7 @@ export async function getCoreServices(): Promise[]> { const { CoreWSProvider } = await import('@services/ws'); const { CorePlatformService } = await import('@services/platform'); const { CoreQRScanService } = await import('@services/qrscan'); + const { CoreLoadingsService } = await import('@services/loadings'); return [ CoreAppProvider, @@ -75,6 +76,7 @@ export async function getCoreServices(): Promise[]> { CoreGroupsProvider, CoreIframeUtilsProvider, CoreLangProvider, + CoreLoadingsService, CoreLocalNotificationsProvider, CoreMimetypeUtilsProvider, CoreNavigatorService, diff --git a/src/core/directives/download-file.ts b/src/core/directives/download-file.ts index 4c67bc45d..dc1fd9428 100644 --- a/src/core/directives/download-file.ts +++ b/src/core/directives/download-file.ts @@ -14,6 +14,7 @@ import { Directive, Input, OnInit, ElementRef } from '@angular/core'; import { CoreFileHelper } from '@services/file-helper'; +import { CoreLoadings } from '@services/loadings'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreWSFile } from '@services/ws'; @@ -48,7 +49,7 @@ export class CoreDownloadFileDirective implements OnInit { ev.preventDefault(); ev.stopPropagation(); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await CoreFileHelper.downloadAndOpenFile(this.file, this.component, this.componentId); diff --git a/src/core/directives/link.ts b/src/core/directives/link.ts index 61ad4c40d..ec463b819 100644 --- a/src/core/directives/link.ts +++ b/src/core/directives/link.ts @@ -28,6 +28,7 @@ import { DomSanitizer } from '@singletons'; import { CoreFilepool } from '@services/filepool'; import { CoreDom } from '@singletons/dom'; import { toBoolean } from '../transforms/boolean'; +import { CoreLoadings } from '@services/loadings'; /** * Directive to open a link in external browser or in the app. @@ -205,7 +206,7 @@ export class CoreLinkDirective implements OnInit { if (isDownloading) { // Wait for the download to finish before opening the file to prevent downloading it twice. - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const path = await CoreFilepool.downloadUrl(currentSite.getId(), href); diff --git a/src/core/features/comments/pages/viewer/viewer.ts b/src/core/features/comments/pages/viewer/viewer.ts index a403084b6..01a1322b8 100644 --- a/src/core/features/comments/pages/viewer/viewer.ts +++ b/src/core/features/comments/pages/viewer/viewer.ts @@ -44,6 +44,7 @@ import { Subscription } from 'rxjs'; import { CoreAnimations } from '@components/animations'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays comments. @@ -311,7 +312,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { */ async addComment(text: string): Promise { CoreKeyboard.close(); - const loadingModal = await CoreDomUtils.showModalLoading('core.sending', true); + const loadingModal = await CoreLoadings.show('core.sending', true); // Freeze the add comment button. this.sending = true; try { diff --git a/src/core/features/contentlinks/classes/module-grade-handler.ts b/src/core/features/contentlinks/classes/module-grade-handler.ts index 02be1dff5..48cbec60a 100644 --- a/src/core/features/contentlinks/classes/module-grade-handler.ts +++ b/src/core/features/contentlinks/classes/module-grade-handler.ts @@ -15,7 +15,7 @@ import { CoreContentLinksAction } from '../services/contentlinks-delegate'; import { CoreContentLinksHandlerBase } from './base-handler'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreCourseHelper } from '@features/course/services/course-helper'; /** @@ -72,7 +72,7 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB return [{ action: async (siteId): Promise => { // Check if userid is the site's current user. - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const site = await CoreSites.getSite(siteId); if (!params.userid || Number(params.userid) == site.getUserId()) { // No user specified or current user. Navigate to module. diff --git a/src/core/features/course/components/module-navigation/module-navigation.ts b/src/core/features/course/components/module-navigation/module-navigation.ts index ce555d494..1023ccfda 100644 --- a/src/core/features/course/components/module-navigation/module-navigation.ts +++ b/src/core/features/course/components/module-navigation/module-navigation.ts @@ -17,6 +17,7 @@ import { CoreCourse, CoreCourseWSSection } from '@features/course/services/cours import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; import { IonContent } from '@ionic/angular'; +import { CoreLoadings } from '@services/loadings'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; @@ -204,7 +205,7 @@ export class CoreCourseModuleNavigationComponent implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); // Re-calculate module in case a new module was made visible. await CoreUtils.ignoreErrors(this.setNextAndPreviousModules(CoreSitesReadingStrategy.PREFER_NETWORK, next, !next)); diff --git a/src/core/features/course/directives/download-module-main-file.ts b/src/core/features/course/directives/download-module-main-file.ts index 5532dd69a..603be6748 100644 --- a/src/core/features/course/directives/download-module-main-file.ts +++ b/src/core/features/course/directives/download-module-main-file.ts @@ -18,6 +18,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course'; import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreUtilsOpenFileOptions } from '@services/utils/utils'; +import { CoreLoadings } from '@services/loadings'; /** * Directive to allow downloading and open the main file of a module. @@ -57,7 +58,7 @@ export class CoreCourseDownloadModuleMainFileDirective implements OnInit { ev.preventDefault(); ev.stopPropagation(); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const courseId = this.courseId ? Number(this.courseId) : undefined; try { diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index ae96fadb4..df9b29f42 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -75,6 +75,7 @@ import { CoreEnrol } from '@features/enrol/services/enrol'; import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate'; import { LazyRoutesModule } from '@/app/app-routing.module'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Prefetch info of a module. @@ -1033,7 +1034,7 @@ export class CoreCourseHelperProvider { * @returns Promise resolved when done. */ async getAndOpenCourse(courseId: number, params?: Params, siteId?: string): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); let course: CoreCourseAnyCourseData | { id: number }; @@ -1442,7 +1443,7 @@ export class CoreCourseHelperProvider { options: CoreCourseNavigateToModuleByInstanceOptions = {}, ): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const module = await CoreCourse.getModuleBasicInfoByInstance(instanceId, modName, { siteId: options.siteId }); @@ -1478,7 +1479,7 @@ export class CoreCourseHelperProvider { let courseId = options.courseId; let sectionId = options.sectionId; - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { if (!courseId || !sectionId) { @@ -1962,7 +1963,7 @@ export class CoreCourseHelperProvider { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); completion.state = completion.state === CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE ? CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE : CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE; diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index 2e6b48830..902d253eb 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -61,6 +61,7 @@ import { asyncObservable } from '@/core/utils/rxjs'; import { firstValueFrom } from 'rxjs'; import { map } from 'rxjs/operators'; import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site'; +import { CoreLoadings } from '@services/loadings'; const ROOT_CACHE_KEY = 'mmCourse:'; @@ -1360,7 +1361,7 @@ export class CoreCourseProvider { return; } - const loading = await CoreDomUtils.showModalLoading(); + const loading = await CoreLoadings.show(); // Wait for site plugins to be fetched. await CoreUtils.ignoreErrors(CoreSitePlugins.waitFetchPlugins()); diff --git a/src/core/features/courses/components/course-list-item/course-list-item.ts b/src/core/features/courses/components/course-list-item/course-list-item.ts index 55013e86b..4cc568930 100644 --- a/src/core/features/courses/components/course-list-item/course-list-item.ts +++ b/src/core/features/courses/components/course-list-item/course-list-item.ts @@ -29,6 +29,7 @@ import { CoreEnrolHelper } from '@features/enrol/services/enrol-helper'; import { CoreDownloadStatusTranslatable } from '@components/download-refresh/download-refresh'; import { toBoolean } from '@/core/transforms/boolean'; import { CorePopovers } from '@services/popovers'; +import { CoreLoadings } from '@services/loadings'; /** * This directive is meant to display an item for a list of courses. @@ -275,7 +276,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await CoreCourseHelper.deleteCourseFiles(this.course.id); diff --git a/src/core/features/courses/services/handlers/base-link-handler.ts b/src/core/features/courses/services/handlers/base-link-handler.ts index 77e082961..e8cf40720 100644 --- a/src/core/features/courses/services/handlers/base-link-handler.ts +++ b/src/core/features/courses/services/handlers/base-link-handler.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourses } from '../courses'; @@ -76,7 +76,7 @@ export class CoreCoursesLinksHandlerBase extends CoreContentLinksHandlerBase { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); // Check if user is enrolled in the course. const hasAccess = await CoreCourseHelper.userHasAccessToCourse(courseId); diff --git a/src/core/features/courses/services/handlers/enrol-push-click.ts b/src/core/features/courses/services/handlers/enrol-push-click.ts index 45ee724b3..c59dd189c 100644 --- a/src/core/features/courses/services/handlers/enrol-push-click.ts +++ b/src/core/features/courses/services/handlers/enrol-push-click.ts @@ -17,6 +17,7 @@ import { Params } from '@angular/router'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate'; import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; +import { CoreLoadings } from '@services/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@services/utils/utils'; @@ -51,7 +52,7 @@ export class CoreCoursesEnrolPushClickHandlerService implements CorePushNotifica async handleClick(notification: CoreCoursesEnrolNotificationData): Promise { const courseId = notification.courseid; - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const result = await CoreCourseHelper.getCourse(courseId, notification.site); diff --git a/src/core/features/courses/services/handlers/request-push-click.ts b/src/core/features/courses/services/handlers/request-push-click.ts index 9bd1cd64c..731589af3 100644 --- a/src/core/features/courses/services/handlers/request-push-click.ts +++ b/src/core/features/courses/services/handlers/request-push-click.ts @@ -24,6 +24,7 @@ import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; import { CorePath } from '@singletons/path'; import { CoreCourses } from '../courses'; +import { CoreLoadings } from '@services/loadings'; /** * Handler for course request push notifications clicks. @@ -66,7 +67,7 @@ export class CoreCoursesRequestPushClickHandlerService implements CorePushNotifi } // Open the course. - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); await CoreUtils.ignoreErrors(CoreCourses.invalidateUserCourses(notification.site)); diff --git a/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts b/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts index dc210b959..467b23340 100644 --- a/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts +++ b/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts @@ -23,6 +23,7 @@ import { CoreToasts, ToastDuration } from '@services/toasts'; import { CoreUtils } from '@services/utils/utils'; import { ModalController } from '@singletons'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays the contact DPO page. @@ -57,7 +58,7 @@ export class CoreDataPrivacyContactDPOComponent implements OnInit { * @inheritdoc */ async ngOnInit(): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); // Get current user email. const userId = CoreSites.getCurrentSiteUserId(); @@ -75,7 +76,7 @@ export class CoreDataPrivacyContactDPOComponent implements OnInit { event.preventDefault(); event.stopPropagation(); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Send the message. diff --git a/src/core/features/dataprivacy/components/newrequest/newrequest.ts b/src/core/features/dataprivacy/components/newrequest/newrequest.ts index 53fde8914..1c29cb690 100644 --- a/src/core/features/dataprivacy/components/newrequest/newrequest.ts +++ b/src/core/features/dataprivacy/components/newrequest/newrequest.ts @@ -24,6 +24,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CoreToasts, ToastDuration } from '@services/toasts'; import { ModalController } from '@singletons'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays the new request page. @@ -100,7 +101,7 @@ export class CoreDataPrivacyNewRequestComponent implements OnInit { event.preventDefault(); event.stopPropagation(); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Send the message. diff --git a/src/core/features/dataprivacy/pages/main/main.ts b/src/core/features/dataprivacy/pages/main/main.ts index 36fd84bd3..35468473f 100644 --- a/src/core/features/dataprivacy/pages/main/main.ts +++ b/src/core/features/dataprivacy/pages/main/main.ts @@ -19,6 +19,7 @@ import { CoreDataPrivacyGetAccessInformationWSResponse, CoreDataPrivacyRequest, } from '@features/dataprivacy/services/dataprivacy'; +import { CoreLoadings } from '@services/loadings'; import { CoreModals } from '@services/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; @@ -123,7 +124,7 @@ export class CoreDataPrivacyMainPage implements OnInit { }); if (succeed) { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await this.refreshContent(); } finally { @@ -149,7 +150,7 @@ export class CoreDataPrivacyMainPage implements OnInit { }); if (succeed) { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await this.refreshContent(); } finally { @@ -175,7 +176,7 @@ export class CoreDataPrivacyMainPage implements OnInit { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await CoreDataPrivacy.cancelDataRequest(requestId); diff --git a/src/core/features/emulator/components/capture-media/capture-media.ts b/src/core/features/emulator/components/capture-media/capture-media.ts index c997268e4..98891194e 100644 --- a/src/core/features/emulator/components/capture-media/capture-media.ts +++ b/src/core/features/emulator/components/capture-media/capture-media.ts @@ -25,6 +25,7 @@ import { CoreCaptureError } from '@classes/errors/captureerror'; import { CoreCanceledError } from '@classes/errors/cancelederror'; import { CorePath } from '@singletons/path'; import { toBoolean } from '@/core/transforms/boolean'; +import { CoreLoadings } from '@services/loadings'; /** * Page to capture media in browser. @@ -211,7 +212,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy { // Get the image from the video and set it to the canvas, using video width/height. const width = this.streamVideo?.nativeElement.videoWidth; const height = this.streamVideo?.nativeElement.videoHeight; - const loadingModal = await CoreDomUtils.showModalLoading(); + const loadingModal = await CoreLoadings.show(); this.imgCanvas.nativeElement.width = width; this.imgCanvas.nativeElement.height = height; @@ -313,7 +314,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy { return; } - const loadingModal = await CoreDomUtils.showModalLoading(); + const loadingModal = await CoreLoadings.show(); try { // Capturing in browser. Write the blob in a file. diff --git a/src/core/features/fileuploader/services/fileuploader-helper.ts b/src/core/features/fileuploader/services/fileuploader-helper.ts index cbbad35a1..19a2e8008 100644 --- a/src/core/features/fileuploader/services/fileuploader-helper.ts +++ b/src/core/features/fileuploader/services/fileuploader-helper.ts @@ -45,6 +45,7 @@ import { CorePromisedValue } from '@classes/promised-value'; import { CorePlatform } from '@services/platform'; import { Chooser } from '@features/native/plugins'; import { CoreToasts } from '@services/toasts'; +import { CoreLoadings } from '@services/loadings'; /** * Helper service to upload files. @@ -75,7 +76,7 @@ export class CoreFileUploaderHelperProvider { mimetypes?: string[], ): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const result = await Chooser.getFileMetadata(mimetypes ? mimetypes.join(',') : undefined); @@ -160,7 +161,7 @@ export class CoreFileUploaderHelperProvider { async copyAndUploadFile(file: IFile | File, upload?: boolean, name?: string): Promise { name = name || file.name; - const modal = await CoreDomUtils.showModalLoading('core.fileuploader.readingfile', true); + const modal = await CoreLoadings.show('core.fileuploader.readingfile', true); let fileEntry: FileEntry | undefined; try { @@ -821,7 +822,7 @@ export class CoreFileUploaderHelperProvider { } // File isn't too large and user confirmed, let's upload. - const modal = await CoreDomUtils.showModalLoading(uploadingStr); + const modal = await CoreLoadings.show(uploadingStr); try { return await CoreFileUploader.uploadFile( diff --git a/src/core/features/grades/services/grades-helper.ts b/src/core/features/grades/services/grades-helper.ts index ab09a7bb1..1c05c1571 100644 --- a/src/core/features/grades/services/grades-helper.ts +++ b/src/core/features/grades/services/grades-helper.ts @@ -43,6 +43,7 @@ import { CoreError } from '@classes/errors/error'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; import { CoreCourseAccess } from '@features/course/services/course-options-delegate'; +import { CoreLoadings } from '@services/loadings'; export const GRADES_PAGE_NAME = 'grades'; export const GRADES_PARTICIPANTS_PAGE_NAME = 'participant-grades'; @@ -441,7 +442,7 @@ export class CoreGradesHelperProvider { moduleId?: number, siteId?: string, ): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); const site = await CoreSites.getSite(siteId); diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index 8c8ccaa14..515b24671 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -41,6 +41,7 @@ import { import { CoreCustomURLSchemes } from '@services/urlschemes'; import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreKeyboard } from '@singletons/keyboard'; +import { CoreLoadings } from '@services/loadings'; /** * Page to enter the user credentials. @@ -290,7 +291,7 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); // Start the authentication process. try { diff --git a/src/core/features/login/pages/email-signup/email-signup.ts b/src/core/features/login/pages/email-signup/email-signup.ts index 0d4c3d952..6202eff90 100644 --- a/src/core/features/login/pages/email-signup/email-signup.ts +++ b/src/core/features/login/pages/email-signup/email-signup.ts @@ -37,6 +37,7 @@ import { CoreSitesFactory } from '@services/sites-factory'; import { EMAIL_SIGNUP_FEATURE_NAME } from '@features/login/constants'; import { CoreInputErrorsMessages } from '@components/input-errors/input-errors'; import { CoreViewer } from '@features/viewer/services/viewer'; +import { CoreLoadings } from '@services/loadings'; /** * Page to signup using email. @@ -306,7 +307,7 @@ export class CoreLoginEmailSignupPage implements OnInit { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); const params: SignupUserWSParams = { username: this.signupForm.value.username.trim().toLowerCase(), @@ -415,7 +416,7 @@ export class CoreLoginEmailSignupPage implements OnInit { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); const params = this.ageVerificationForm.value; diff --git a/src/core/features/login/pages/forgotten-password/forgotten-password.ts b/src/core/features/login/pages/forgotten-password/forgotten-password.ts index 02acc8107..1e29997db 100644 --- a/src/core/features/login/pages/forgotten-password/forgotten-password.ts +++ b/src/core/features/login/pages/forgotten-password/forgotten-password.ts @@ -25,6 +25,7 @@ import { CoreSitePublicConfigResponse, CoreUnauthenticatedSite } from '@classes/ import { CoreUserSupportConfig } from '@features/user/classes/support/support-config'; import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config'; import { CoreSitesFactory } from '@services/sites-factory'; +import { CoreLoadings } from '@services/loadings'; /** * Page to recover a forgotten password. @@ -90,7 +91,7 @@ export class CoreLoginForgottenPasswordPage implements OnInit { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); const isMail = field === 'email'; try { diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index 181ef2f13..b619dc568 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -33,6 +33,7 @@ import { SafeHtml } from '@angular/platform-browser'; import { CoreSitePublicConfigResponse } from '@classes/sites/unauthenticated-site'; import { ALWAYS_SHOW_LOGIN_FORM_CHANGED, FORGOTTEN_PASSWORD_FEATURE_NAME } from '@features/login/constants'; import { CoreKeyboard } from '@singletons/keyboard'; +import { CoreLoadings } from '@services/loadings'; /** * Page to enter the user password to reconnect to a site. @@ -243,7 +244,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { // Start the authentication process. diff --git a/src/core/features/login/pages/site/site.ts b/src/core/features/login/pages/site/site.ts index 327202357..92ce70fa3 100644 --- a/src/core/features/login/pages/site/site.ts +++ b/src/core/features/login/pages/site/site.ts @@ -48,6 +48,7 @@ import { CoreUnauthenticatedSite } from '@classes/sites/unauthenticated-site'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreModals } from '@services/modals'; import { CoreQRScan } from '@services/qrscan'; +import { CoreLoadings } from '@services/loadings'; /** * Site (url) chooser when adding a new site. @@ -322,7 +323,7 @@ export class CoreLoginSitePage implements OnInit { } else { // Not a demo site. - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); let checkResult: CoreSiteCheckResponse; @@ -361,7 +362,7 @@ export class CoreLoginSitePage implements OnInit { * @returns Promise resolved when done. */ protected async loginDemoSite(siteData: CoreSitesDemoSiteData): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const data = await CoreSites.getUserToken(siteData.url, siteData.username, siteData.password); @@ -595,7 +596,7 @@ export class CoreLoginSitePage implements OnInit { */ protected async treatErrorInAuthenticationCustomURL(customURL: string, error: CoreCustomURLSchemesHandleError): Promise { const siteUrl = error.data?.siteUrl || ''; - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); // Set the site URL in the input. this.siteForm.controls.siteUrl.setValue(siteUrl); diff --git a/src/core/features/login/pages/sites/sites.ts b/src/core/features/login/pages/sites/sites.ts index 38a8d4bb3..82a980ad0 100644 --- a/src/core/features/login/pages/sites/sites.ts +++ b/src/core/features/login/pages/sites/sites.ts @@ -20,6 +20,7 @@ import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/logi import { CoreNavigator } from '@services/navigator'; import { CoreFilter } from '@features/filter/services/filter'; import { CoreAnimations } from '@components/animations'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays the list of sites stored in the device. @@ -105,7 +106,7 @@ export class CoreLoginSitesPage implements OnInit { * @returns Promise resolved when done. */ async login(site: CoreSiteBasicInfo): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const loggedIn = await CoreSites.loadSite(site.id); diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index 3bb4c55e7..d3d9b416b 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -59,6 +59,7 @@ import { import { LazyRoutesModule } from '@/app/app-routing.module'; import { CoreSiteError, CoreSiteErrorDebug } from '@classes/errors/siteerror'; import { CoreQRScan } from '@services/qrscan'; +import { CoreLoadings } from '@services/loadings'; /** * Helper provider that provides some common features regarding authentication. @@ -175,7 +176,7 @@ export class CoreLoginHelperProvider { } // Check if password reset can be done through the app. - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const canReset = await this.canRequestPasswordReset(siteUrl); @@ -649,7 +650,7 @@ export class CoreLoginHelperProvider { return false; } - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const loginUrl = await this.prepareForSSOLogin(siteUrl, undefined, launchUrl, redirectData, { @@ -686,7 +687,7 @@ export class CoreLoginHelperProvider { launchUrl?: string, redirectData?: CoreRedirectPayload, ): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const loginUrl = await this.prepareForSSOLogin(siteUrl, service, launchUrl, redirectData); @@ -1082,7 +1083,7 @@ export class CoreLoginHelperProvider { await CoreDomUtils.showConfirm(message, title, okText, cancelText); // Call the WS to resend the confirmation email. - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); const data = { username, password }; const preSets = { siteUrl }; @@ -1118,7 +1119,7 @@ export class CoreLoginHelperProvider { * @returns Promise. */ protected async canResendEmail(siteUrl: string): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); // We don't have site info before login, the only way to check if the WS is available is by calling it. try { diff --git a/src/core/features/policy/pages/acceptances/acceptances.ts b/src/core/features/policy/pages/acceptances/acceptances.ts index 9f4513565..0497847ed 100644 --- a/src/core/features/policy/pages/acceptances/acceptances.ts +++ b/src/core/features/policy/pages/acceptances/acceptances.ts @@ -27,6 +27,7 @@ import { CORE_DATAPRIVACY_FEATURE_NAME, CORE_DATAPRIVACY_PAGE_NAME } from '@feat import { CoreNavigator } from '@services/navigator'; import { CoreDataPrivacy } from '@features/dataprivacy/services/dataprivacy'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Page to view user acceptances. @@ -212,7 +213,7 @@ export class CorePolicyAcceptancesPage implements OnInit, OnDestroy { event.preventDefault(); event.stopPropagation(); - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { await CorePolicy.setUserAcceptances({ [policy.versionid]: accept ? 1 : 0 }); diff --git a/src/core/features/policy/pages/site-policy/site-policy.ts b/src/core/features/policy/pages/site-policy/site-policy.ts index e59851459..55ee737d4 100644 --- a/src/core/features/policy/pages/site-policy/site-policy.ts +++ b/src/core/features/policy/pages/site-policy/site-policy.ts @@ -32,6 +32,7 @@ import { Subscription } from 'rxjs'; import { CoreDom } from '@singletons/dom'; import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/loadings'; /** * Page to accept a site policy. @@ -375,7 +376,7 @@ export class CorePolicySitePolicyPage implements OnInit, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { if (!this.isPoliciesURL) { diff --git a/src/core/features/rating/components/rate/rate.ts b/src/core/features/rating/components/rate/rate.ts index 5768ce812..cf6729efa 100644 --- a/src/core/features/rating/components/rate/rate.ts +++ b/src/core/features/rating/components/rate/rate.ts @@ -27,6 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CoreToasts, ToastDuration } from '@services/toasts'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; +import { CoreLoadings } from '@services/loadings'; /** * Component that displays the user rating select. @@ -130,7 +131,7 @@ export class CoreRatingRateComponent implements OnChanges, OnDestroy { return; } - const modal = await CoreDomUtils.showModalLoading('core.sending', true); + const modal = await CoreLoadings.show('core.sending', true); try { const response = await CoreRating.addRating( diff --git a/src/core/features/settings/pages/dev/dev.ts b/src/core/features/settings/pages/dev/dev.ts index 7c9464ffd..ac6b3a070 100644 --- a/src/core/features/settings/pages/dev/dev.ts +++ b/src/core/features/settings/pages/dev/dev.ts @@ -202,7 +202,7 @@ export class CoreSettingsDevPage implements OnInit { * Invalidate app caches. */ async invalidateCaches(): Promise { - const success = await CoreDomUtils.showOperationModals('Invalidating caches', true, async () => { + const success = await CoreDomUtils.showOperationModals('Invalidating caches', false, async () => { await CoreCacheManager.invalidate(); return true; diff --git a/src/core/features/siteplugins/classes/call-ws-click-directive.ts b/src/core/features/siteplugins/classes/call-ws-click-directive.ts index 43f4b8bd2..6525b4366 100644 --- a/src/core/features/siteplugins/classes/call-ws-click-directive.ts +++ b/src/core/features/siteplugins/classes/call-ws-click-directive.ts @@ -20,6 +20,7 @@ import { Translate } from '@singletons'; import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content'; import { CoreSitePluginsCallWSBaseDirective } from './call-ws-directive'; import { toBoolean } from '@/core/transforms/boolean'; +import { CoreLoadings } from '@services/loadings'; /** * Base class for directives to call a WS when the element is clicked. @@ -67,7 +68,7 @@ export class CoreSitePluginsCallWSOnClickBaseDirective extends CoreSitePluginsCa * @inheritdoc */ protected async callWS(): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { await super.callWS(); diff --git a/src/core/features/user/pages/about/about.ts b/src/core/features/user/pages/about/about.ts index e5d3c71ef..54ff793a9 100644 --- a/src/core/features/user/pages/about/about.ts +++ b/src/core/features/user/pages/about/about.ts @@ -33,6 +33,7 @@ import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuplo import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { Translate } from '@singletons'; import { CoreUrl } from '@singletons/url'; +import { CoreLoadings } from '@services/loadings'; /** * Page that displays info about a user. @@ -176,7 +177,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { try { const result = await CoreFileUploaderHelper.selectAndUploadFile(maxSize, title, mimetypes); - modal = await CoreDomUtils.showModalLoading('core.sending', true); + modal = await CoreLoadings.show('core.sending', true); const profileImageURL = await CoreUser.changeProfilePicture(result.itemid, this.userId, this.site.getId()); diff --git a/src/core/services/loadings.ts b/src/core/services/loadings.ts new file mode 100644 index 000000000..a5d3c8007 --- /dev/null +++ b/src/core/services/loadings.ts @@ -0,0 +1,78 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable } from '@angular/core'; +import { CoreIonLoadingElement } from '@classes/ion-loading'; +import { Translate, makeSingleton } from '@singletons'; + +/** + * Handles application loading. + */ +@Injectable({ providedIn: 'root' }) +export class CoreLoadingsService { + + protected activeLoadingModals: CoreIonLoadingElement[] = []; + + /** + * Displays a loading modal window. + * + * @param text The text of the modal window. Default: core.loading. + * @param needsTranslate Whether the 'text' needs to be translated. + * @returns Loading element instance. + * @description + * Usage: + * let modal = await CoreLoading.show(myText); + * ... + * modal.dismiss(); + */ + async show(text?: string, needsTranslate?: boolean): Promise { + if (!text) { + text = Translate.instant('core.loading'); + } else if (needsTranslate) { + text = Translate.instant(text); + } + + const loading = new CoreIonLoadingElement(text); + + loading.onDismiss(() => { + const index = this.activeLoadingModals.indexOf(loading); + + if (index !== -1) { + this.activeLoadingModals.splice(index, 1); + } + }); + + this.activeLoadingModals.push(loading); + + await loading.present(); + + return loading; + } + + /** + * Pauses the active loading modal. + */ + async pauseActiveModals(): Promise { + await Promise.all(this.activeLoadingModals.slice(0).reverse().map(modal => modal.pause())); + } + + /** + * Resumes the active loading modals. + */ + async resumeActiveModals(): Promise { + await Promise.all(this.activeLoadingModals.map(modal => modal.resume())); + } + +} +export const CoreLoadings = makeSingleton(CoreLoadingsService); diff --git a/src/core/services/navigator.ts b/src/core/services/navigator.ts index 5bb2c0be2..407121ce9 100644 --- a/src/core/services/navigator.ts +++ b/src/core/services/navigator.ts @@ -18,7 +18,6 @@ import { ActivatedRoute, ActivatedRouteSnapshot, Data, NavigationEnd, Params, Ur import { NavigationOptions } from '@ionic/angular/common/providers/nav-controller'; import { CoreConstants } from '@/core/constants'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMainMenu } from '@features/mainmenu/services/mainmenu'; import { CoreObject } from '@singletons/object'; import { CoreSites } from '@services/sites'; @@ -33,6 +32,7 @@ import { CorePlatform } from '@services/platform'; import { filter } from 'rxjs/operators'; import { CorePromisedValue } from '@classes/promised-value'; import { BehaviorSubject } from 'rxjs'; +import { CoreLoadings } from './loadings'; /** * Redirect payload. @@ -232,7 +232,7 @@ export class CoreNavigatorService { // If we are not logged into the site, load the site. if (!CoreSites.isLoggedIn()) { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { const loggedIn = await CoreSites.loadSite(siteId, { diff --git a/src/core/services/urlschemes.ts b/src/core/services/urlschemes.ts index b70a5542a..530c303c7 100644 --- a/src/core/services/urlschemes.ts +++ b/src/core/services/urlschemes.ts @@ -30,6 +30,7 @@ import { CoreDomUtils } from './utils/dom'; import { CoreTextErrorObject, CoreTextUtils } from './utils/text'; import { CoreUrl } from '@singletons/url'; import { CoreUtils } from './utils/utils'; +import { CoreLoadings } from './loadings'; /* * Provider to handle custom URL schemes. @@ -110,7 +111,7 @@ export class CoreCustomURLSchemesProvider { // Some sites add a # at the end of the URL. If it's there, remove it. url = url.replace(/\/?(#.*)?\/?$/, ''); - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); let data: CoreCustomURLSchemesParams; // Get the data from the URL. diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 212909601..f939451db 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -53,6 +53,7 @@ import { fixOverlayAriaHidden } from '@/core/utils/fix-aria-hidden'; import { CoreModals, OpenModalOptions } from '@services/modals'; import { CorePopovers, OpenPopoverOptions } from '@services/popovers'; import { CoreViewer } from '@features/viewer/services/viewer'; +import { CoreLoadings } from '@services/loadings'; /* * "Utils" service with helper functions for UI, DOM elements and HTML code. @@ -71,7 +72,6 @@ export class CoreDomUtilsProvider { protected matchesFunctionName?: string; // Name of the "matches" function to use when simulating a closest call. protected debugDisplay = false; // Whether to display debug messages. Store it in a variable to make it synchronous. protected displayedAlerts: Record = {}; // To prevent duplicated alerts. - protected activeLoadingModals: CoreIonLoadingElement[] = []; protected logger: CoreLogger; constructor() { @@ -857,7 +857,7 @@ export class CoreDomUtilsProvider { const alert = await AlertController.create(options); if (Object.keys(this.displayedAlerts).length === 0) { - await Promise.all(this.activeLoadingModals.slice(0).reverse().map(modal => modal.pause())); + await CoreLoadings.pauseActiveModals(); } // eslint-disable-next-line promise/catch-or-return @@ -883,7 +883,7 @@ export class CoreDomUtilsProvider { // eslint-disable-next-line promise/always-return if (Object.keys(this.displayedAlerts).length === 0) { - await Promise.all(this.activeLoadingModals.map(modal => modal.resume())); + await CoreLoadings.resumeActiveModals(); } }); @@ -1151,34 +1151,10 @@ export class CoreDomUtilsProvider { * @param text The text of the modal window. Default: core.loading. * @param needsTranslate Whether the 'text' needs to be translated. * @returns Loading element instance. - * @description - * Usage: - * let modal = await domUtils.showModalLoading(myText); - * ... - * modal.dismiss(); + * @deprecated since 4.5. Use CoreLoading.show instead. */ async showModalLoading(text?: string, needsTranslate?: boolean): Promise { - if (!text) { - text = Translate.instant('core.loading'); - } else if (needsTranslate) { - text = Translate.instant(text); - } - - const loading = new CoreIonLoadingElement(text); - - loading.onDismiss(() => { - const index = this.activeLoadingModals.indexOf(loading); - - if (index !== -1) { - this.activeLoadingModals.splice(index, 1); - } - }); - - this.activeLoadingModals.push(loading); - - await loading.present(); - - return loading; + return CoreLoadings.show(text, needsTranslate); } /** @@ -1190,7 +1166,7 @@ export class CoreDomUtilsProvider { * @returns Operation result. */ async showOperationModals(text: string, needsTranslate: boolean, operation: () => Promise): Promise { - const modal = await this.showModalLoading(text, needsTranslate); + const modal = await CoreLoadings.show(text, needsTranslate); try { return await operation(); diff --git a/src/core/services/utils/iframe.ts b/src/core/services/utils/iframe.ts index 39975ce21..e2e5aa068 100644 --- a/src/core/services/utils/iframe.ts +++ b/src/core/services/utils/iframe.ts @@ -36,6 +36,7 @@ import { CoreMimetypeUtils } from './mimetype'; import { CoreFilepool } from '@services/filepool'; import { CoreSite } from '@classes/sites/site'; import { CoreNative } from '@features/native/services/native'; +import { CoreLoadings } from '@services/loadings'; type CoreFrameElement = FrameElement & { window?: Window; @@ -674,7 +675,7 @@ export class CoreIframeUtilsProvider { * @param options Options */ async frameLaunchExternal(url: string, options: LaunchExternalOptions = {}): Promise { - const modal = await CoreDomUtils.showModalLoading(); + const modal = await CoreLoadings.show(); try { if (!CoreNetwork.isOnline()) { diff --git a/src/testing/utils.ts b/src/testing/utils.ts index 0df713ae3..1cbe0ea39 100644 --- a/src/testing/utils.ts +++ b/src/testing/utils.ts @@ -27,7 +27,7 @@ import { CoreNetwork } from '@services/network'; import { CorePlatform } from '@services/platform'; import { CoreDB } from '@services/db'; import { CoreNavigator, CoreNavigatorService } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreLoadings } from '@services/loadings'; import { TranslateModule, TranslateService, TranslateStore } from '@ngx-translate/core'; import { CoreIonLoadingElement } from '@classes/ion-loading'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; @@ -71,8 +71,8 @@ const DEFAULT_SERVICE_SINGLETON_MOCKS: [CoreSingletonProxy, unknown][] = [ isOnline: () => true, onChange: () => new Observable(), })], - [CoreDomUtils, mock({ - showModalLoading: () => Promise.resolve(mock({ dismiss: jest.fn() })), + [CoreLoadings, mock({ + show: () => Promise.resolve(mock({ dismiss: jest.fn() })), })], [CoreUtils, mock(new CoreUtilsProvider(), { nextTick: () => Promise.resolve(),