Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile 4653 #4232

Merged
merged 29 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
62d7251
MOBILE-4653 chore: Use of default classes when importing
crazyserver Oct 29, 2024
e04264b
MOBILE-4653 chore: Migrate styleUrls to styleUrl when possible
crazyserver Oct 29, 2024
d1cae14
MOBILE-4653 chore: Migrate site plugins to standalone components
crazyserver Nov 14, 2024
3959df9
MOBILE-4653 calendar: Partially decouple calendar
crazyserver Nov 15, 2024
dba799f
MOBILE-4653 sites: Move CoreSite constants
crazyserver Nov 6, 2024
8846de8
MOBILE-4653 courses: Move CoreCoursesProvider constants
crazyserver Nov 6, 2024
602c673
MOBILE-4653 chore: Remove 4.2 deprecated functions
crazyserver Nov 6, 2024
dab0ea6
MOBILE-4653 course: Move CoreCourseProvider constants
crazyserver Nov 15, 2024
e69eed4
MOBILE-4653 messages: Move AddonMessages constants
crazyserver Nov 6, 2024
40b200d
MOBILE-4653 handlers: Decouple handlers from its components
crazyserver Nov 6, 2024
1eb548e
MOBILE-4653 sync: Decouple Sync services from related main service
crazyserver Nov 15, 2024
2485fb3
MOBILE-4653 courses: Decouple deprecated functions on courses
crazyserver Nov 6, 2024
61a33c7
MOBILE-4653 sitehome: Decouple forum from sitehome
crazyserver Nov 6, 2024
17115a2
MOBILE-4653 mainmenu: Move Mainmenu constants
crazyserver Nov 6, 2024
efd364f
MOBILE-4653 chore: Mixture of typos
crazyserver Nov 6, 2024
966edb8
MOBILE-4653 reminders: Move reminders constants
crazyserver Nov 15, 2024
bc35290
MOBILE-4653 app: Divide CoreApp in many services
crazyserver Nov 15, 2024
fe0d6a0
MOBILE-4653 utils: Move IAB related utils functions
crazyserver Nov 15, 2024
7ea188a
MOBILE-4653 utils: Move promise related utils functions
crazyserver Nov 15, 2024
94b0266
MOBILE-4653 utils: Move error related utils functions
crazyserver Nov 11, 2024
5e3d233
MOBILE-4653 utils: Move file related utils functions
crazyserver Nov 15, 2024
8ba7845
MOBILE-4653 utils: Move file related utils functions
crazyserver Nov 15, 2024
e72fea3
MOBILE-4653 utils: Move opener related utils functions
crazyserver Nov 15, 2024
453a2bd
MOBILE-4653 utils: Move country related utils functions
crazyserver Nov 15, 2024
96f3be2
MOBILE-4653 utils: Move object and array related utils functions
crazyserver Nov 15, 2024
f75bcea
MOBILE-4653 utils: Completely migrate utils to singleton
crazyserver Nov 15, 2024
43606fb
MOBILE-4653 lang: Lazy load multilang handlers from lang service
crazyserver Nov 11, 2024
0a37db2
MOBILE-4653 chore: Fix singleton constructors and compiler
crazyserver Nov 11, 2024
f1a488d
MOBILE-4653 login: Improvements to easily change classes and logins
crazyserver Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
cat circular-dependencies
lines=$(cat circular-dependencies | wc -l)
echo "Total circular dependencies: $lines"
test $lines -eq 130
test $lines -eq 90
- name: JavaScript code compatibility
run: |
npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Object.hasOwn"
Expand Down
2 changes: 1 addition & 1 deletion src/addons/badges/badge-lazy.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ const routes: Routes = [
RouterModule.forChild(routes),
],
})
export class AddonBadgeLazyModule {}
export default class AddonBadgeLazyModule {}
2 changes: 1 addition & 1 deletion src/addons/badges/badgeclass-lazy.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ const routes: Routes = [
AddonBadgesBadgeClassPage,
],
})
export class AddonBadgeClassLazyModule {}
export default class AddonBadgeClassLazyModule {}
2 changes: 1 addition & 1 deletion src/addons/badges/badges-lazy.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ const routes: Routes = [
AddonBadgesUserBadgesPage,
],
})
export class AddonBadgesLazyModule {}
export default class AddonBadgesLazyModule {}
6 changes: 3 additions & 3 deletions src/addons/badges/badges.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ export async function getBadgesServices(): Promise<Type<unknown>[]> {
const mainMenuRoutes: Routes = [
{
path: 'badge',
loadChildren: () => import('./badge-lazy.module').then(m => m.AddonBadgeLazyModule),
loadChildren: () => import('./badge-lazy.module'),
},
{
path: 'badges',
loadChildren: () => import('./badges-lazy.module').then(m => m.AddonBadgesLazyModule),
loadChildren: () => import('./badges-lazy.module'),
},
{
path: 'badgeclass',
loadChildren: () => import('./badgeclass-lazy.module').then(m => m.AddonBadgeClassLazyModule),
loadChildren: () => import('./badgeclass-lazy.module'),
},
];

Expand Down
4 changes: 2 additions & 2 deletions src/addons/badges/pages/badge-class/badge-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import { Component, OnInit } from '@angular/core';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { CorePromiseUtils } from '@singletons/promise-utils';
import { CoreNavigator } from '@services/navigator';
import { ActivatedRoute } from '@angular/router';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
Expand Down Expand Up @@ -81,7 +81,7 @@ export class AddonBadgesBadgeClassPage implements OnInit {
* @param refresher Refresher.
*/
async refreshBadgeClass(refresher?: HTMLIonRefresherElement): Promise<void> {
await CoreUtils.ignoreErrors(AddonBadges.invalidateBadgeClass(this.badgeId));
await CorePromiseUtils.ignoreErrors(AddonBadges.invalidateBadgeClass(this.badgeId));

await this.fetchBadgeClass();

Expand Down
6 changes: 3 additions & 3 deletions src/addons/badges/pages/issued-badge/issued-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreSites } from '@services/sites';
import { CoreUser } from '@features/user/services/user';
import { AddonBadges, AddonBadgesUserBadge } from '../../services/badges';
import { CoreUtils } from '@services/utils/utils';
import { CorePromiseUtils } from '@singletons/promise-utils';
import { CoreCourses } from '@features/courses/services/courses';
import { CoreNavigator } from '@services/navigator';
import { ActivatedRoute } from '@angular/router';
Expand Down Expand Up @@ -151,12 +151,12 @@ export class AddonBadgesIssuedBadgePage implements OnInit, OnDestroy {
* @param refresher Refresher.
*/
async refreshBadges(refresher?: HTMLIonRefresherElement): Promise<void> {
await CoreUtils.allPromisesIgnoringErrors([
await CorePromiseUtils.allPromisesIgnoringErrors([
AddonBadges.invalidateUserBadges(this.courseId, this.userId),
AddonBadges.invalidateUserBadgeByHash(this.badgeHash),
]);

await CoreUtils.ignoreErrors(Promise.all([
await CorePromiseUtils.ignoreErrors(Promise.all([
this.fetchIssuedBadge(),
]));

Expand Down
6 changes: 3 additions & 3 deletions src/addons/badges/pages/user-badges/user-badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { AddonBadges, AddonBadgesUserBadge } from '../../services/badges';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CorePromiseUtils } from '@singletons/promise-utils';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { CoreNavigator } from '@services/navigator';
import { CoreListItemsManager } from '@classes/items-management/list-items-manager';
Expand Down Expand Up @@ -90,13 +90,13 @@ export class AddonBadgesUserBadgesPage implements AfterViewInit, OnDestroy {
* @param refresher Refresher.
*/
async refreshBadges(refresher?: HTMLIonRefresherElement): Promise<void> {
await CoreUtils.ignoreErrors(
await CorePromiseUtils.ignoreErrors(
AddonBadges.invalidateUserBadges(
this.badges.getSource().COURSE_ID,
this.badges.getSource().USER_ID,
),
);
await CoreUtils.ignoreErrors(this.badges.reload());
await CorePromiseUtils.ignoreErrors(this.badges.reload());

refresher?.complete();
}
Expand Down
8 changes: 4 additions & 4 deletions src/addons/badges/services/badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
import { CoreError } from '@classes/errors/error';
import { CoreCacheUpdateFrequency } from '@/core/constants';

const ROOT_CACHE_KEY = 'mmaBadges:';

Expand Down Expand Up @@ -70,7 +70,7 @@ export class AddonBadgesProvider {
};
const preSets = {
cacheKey: this.getBadgesCacheKey(courseId, userId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
updateFrequency: CoreCacheUpdateFrequency.RARELY,
};

const response = await site.read<AddonBadgesGetUserBadgesWSResponse>('core_badges_get_user_badges', data, preSets);
Expand Down Expand Up @@ -133,7 +133,7 @@ export class AddonBadgesProvider {
};
const preSets = {
cacheKey: this.getUserBadgeByHashCacheKey(hash),
updateFrequency: CoreSite.FREQUENCY_RARELY,
updateFrequency: CoreCacheUpdateFrequency.RARELY,
};

const response = await site.read<AddonBadgesGetUserBadgeByHashWSResponse>(
Expand Down Expand Up @@ -190,7 +190,7 @@ export class AddonBadgesProvider {
};
const preSets = {
cacheKey: this.getBadgeClassCacheKey(id),
updateFrequency: CoreSite.FREQUENCY_RARELY,
updateFrequency: CoreCacheUpdateFrequency.RARELY,
};

const response = await site.read<AddonBadgesGetBadgeClassWSResponse>(
Expand Down
5 changes: 3 additions & 2 deletions src/addons/badges/services/handlers/push-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

import { Injectable } from '@angular/core';

import { CoreUtils } from '@services/utils/utils';
import { CoreUtils } from '@singletons/utils';
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
import { AddonBadges } from '../badges';
import { makeSingleton } from '@singletons';
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
import { CoreNavigator } from '@services/navigator';
import { AddonBadgesHelper } from '../badges-helper';
import { CorePromiseUtils } from '@singletons/promise-utils';

/**
* Handler for badges push notifications clicks.
Expand Down Expand Up @@ -72,7 +73,7 @@ export class AddonBadgesPushClickHandlerService implements CorePushNotifications
}

// No hash, open the list of user badges.
await CoreUtils.ignoreErrors(
await CorePromiseUtils.ignoreErrors(
AddonBadges.invalidateUserBadges(
0,
Number(notification.usertoid),
Expand Down
5 changes: 3 additions & 2 deletions src/addons/badges/services/handlers/tag-area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import { Injectable, Type } from '@angular/core';
import { CoreTagFeedComponent } from '@features/tag/components/feed/feed';
import { CoreTagAreaHandler } from '@features/tag/services/tag-area-delegate';
import { CoreTagFeedElement, CoreTagHelper } from '@features/tag/services/tag-helper';
import { makeSingleton } from '@singletons';
Expand Down Expand Up @@ -45,7 +44,9 @@ export class AddonBadgesTagAreaHandlerService implements CoreTagAreaHandler {
/**
* @inheritdoc
*/
getComponent(): Type<unknown> | Promise<Type<unknown>> {
async getComponent(): Promise<Type<unknown>> {
const { CoreTagFeedComponent } = await import('@features/tag/components/feed/feed');

return CoreTagFeedComponent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { CoreBlockBaseComponent } from '@features/block/classes/base-block-compo
import { CoreSites } from '@services/sites';
import { ContextLevel, CoreConstants } from '@/core/constants';
import { Translate } from '@singletons';
import { CoreUtils } from '@services/utils/utils';
import { CoreObject } from '@singletons/object';
import { CoreNavigator } from '@services/navigator';
import { CoreCourseHelper } from '@features/course/services/course-helper';
import { CoreUrl } from '@singletons/url';
Expand Down Expand Up @@ -106,7 +106,7 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i
});

// Sort the modnames alphabetically.
modFullNames = CoreUtils.sortValues(modFullNames);
modFullNames = CoreObject.sortValues(modFullNames);
for (const modName in modFullNames) {
const iconModName = modName === 'resources' ? 'page' : modName;

Expand Down
4 changes: 2 additions & 2 deletions src/addons/block/calendarmonth/services/block-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler
import { CoreCourseBlock } from '@features/course/services/course';
import { Params } from '@angular/router';
import { makeSingleton } from '@singletons';
import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu';
import { ContextLevel } from '@/core/constants';
import { ADDON_CALENDAR_PAGE_NAME } from '@addons/calendar/constants';

/**
* Block handler.
Expand All @@ -46,7 +46,7 @@ export class AddonBlockCalendarMonthHandlerService extends CoreBlockBaseHandler
title: 'addon.block_calendarmonth.pluginname',
class: 'addon-block-calendar-month',
component: CoreBlockOnlyTitleComponent,
link: AddonCalendarMainMenuHandlerService.PAGE_NAME,
link: ADDON_CALENDAR_PAGE_NAME,
linkParams: linkParams,
navOptions: {
preferCurrentTab: false,
Expand Down
4 changes: 2 additions & 2 deletions src/addons/block/calendarupcoming/services/block-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler
import { CoreCourseBlock } from '@features/course/services/course';
import { Params } from '@angular/router';
import { makeSingleton } from '@singletons';
import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu';
import { CoreSites } from '@services/sites';
import { ContextLevel } from '@/core/constants';
import { ADDON_CALENDAR_PAGE_NAME } from '@addons/calendar/constants';

/**
* Block handler.
Expand Down Expand Up @@ -51,7 +51,7 @@ export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandl
title: 'addon.block_calendarupcoming.pluginname',
class: 'addon-block-calendar-upcoming',
component: CoreBlockOnlyTitleComponent,
link: AddonCalendarMainMenuHandlerService.PAGE_NAME,
link: ADDON_CALENDAR_PAGE_NAME,
linkParams: linkParams,
};
}
Expand Down
27 changes: 16 additions & 11 deletions src/addons/block/myoverview/components/myoverview/myoverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import {
CoreCoursesProvider,
CoreCourses,
CoreCoursesMyCoursesUpdatedEventData,
CoreCourseSummaryData,
Expand All @@ -27,7 +26,7 @@ import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/servi
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
import { CoreBlockBaseComponent } from '@features/block/classes/base-block-component';
import { CoreSite } from '@classes/sites/site';
import { CoreUtils } from '@services/utils/utils';
import { CorePromiseUtils } from '@singletons/promise-utils';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreText } from '@singletons/text';
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
Expand All @@ -38,6 +37,12 @@ import { PageLoadsManager } from '@classes/page-loads-manager';
import { DownloadStatus } from '@/core/constants';
import { CoreSharedModule } from '@/core/shared.module';
import { CoreCoursesComponentsModule } from '@features/courses/components/components.module';
import {
CORE_COURSES_MY_COURSES_UPDATED_EVENT,
CoreCoursesMyCoursesUpdatedEventAction,
CORE_COURSES_STATE_FAVOURITE,
CORE_COURSES_STATE_HIDDEN,
} from '@features/courses/constants';

const FILTER_PRIORITY: AddonBlockMyOverviewTimeFilters[] =
['all', 'inprogress', 'future', 'past', 'favourite', 'allincludinghidden', 'hidden'];
Expand Down Expand Up @@ -137,7 +142,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
}, CoreSites.getCurrentSiteId());

this.coursesObserver = CoreEvents.on(
CoreCoursesProvider.EVENT_MY_COURSES_UPDATED,
CORE_COURSES_MY_COURSES_UPDATED_EVENT,
(data) => {
this.refreshCourseList(data);
},
Expand Down Expand Up @@ -238,7 +243,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem

// Invalidate course completion data.
promises.push(this.invalidateCourseList().finally(() =>
CoreUtils.allPromises(courseIds.map((courseId) =>
CorePromiseUtils.allPromises(courseIds.map((courseId) =>
AddonCourseCompletion.invalidateCourseCompletion(courseId)))));

if (courseIds.length == 1) {
Expand All @@ -250,7 +255,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
promises.push(CoreCourses.invalidateCoursesByField('ids', courseIds.join(',')));
}

await CoreUtils.allPromises(promises).finally(() => {
await CorePromiseUtils.allPromises(promises).finally(() => {
this.prefetchIconsInitialized = false;
});
}
Expand Down Expand Up @@ -428,37 +433,37 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
}

/**
* Refresh course list based on a EVENT_MY_COURSES_UPDATED event.
* Refresh course list based on a CORE_COURSES_MY_COURSES_UPDATED_EVENT event.
*
* @param data Event data.
* @returns Promise resolved when done.
*/
protected async refreshCourseList(data: CoreCoursesMyCoursesUpdatedEventData): Promise<void> {
if (data.action == CoreCoursesProvider.ACTION_ENROL) {
if (data.action === CoreCoursesMyCoursesUpdatedEventAction.ENROL) {
// Always update if user enrolled in a course.
return this.refreshContent(true);
}

const course = this.allCourses.find((course) => course.id == data.courseId);
if (data.action == CoreCoursesProvider.ACTION_STATE_CHANGED) {
if (data.action === CoreCoursesMyCoursesUpdatedEventAction.STATE_CHANGED) {
if (!course) {
// Not found, use WS update.
return this.refreshContent(true);
}

if (data.state == CoreCoursesProvider.STATE_FAVOURITE) {
if (data.state === CORE_COURSES_STATE_FAVOURITE) {
course.isfavourite = !!data.value;
}

if (data.state == CoreCoursesProvider.STATE_HIDDEN) {
if (data.state === CORE_COURSES_STATE_HIDDEN) {
course.hidden = !!data.value;
}

await this.invalidateCourseList();
await this.filterCourses();
}

if (data.action == CoreCoursesProvider.ACTION_VIEW && data.courseId != CoreSites.getCurrentSiteHomeId()) {
if (data.action === CoreCoursesMyCoursesUpdatedEventAction.VIEW && data.courseId != CoreSites.getCurrentSiteHomeId()) {
if (!course) {
// Not found, use WS update.
return this.refreshContent(true);
Expand Down
Loading