diff --git a/src/addons/blog/pages/index/index.ts b/src/addons/blog/pages/index/index.ts index 822973610e4..525b54dea96 100644 --- a/src/addons/blog/pages/index/index.ts +++ b/src/addons/blog/pages/index/index.ts @@ -363,10 +363,12 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { * @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading. * @returns Resolved when done. */ - loadMore(infiniteComplete?: () => void): Promise { - return this.fetchEntries(false).finally(() => { - infiniteComplete && infiniteComplete(); - }); + async loadMore(infiniteComplete?: () => void): Promise { + try { + return await this.fetchEntries(false); + } finally { + infiniteComplete?.(); + } } /** diff --git a/src/addons/mod/forum/pages/discussion/discussion.ts b/src/addons/mod/forum/pages/discussion/discussion.ts index 3e89ed32068..10e56e0de48 100644 --- a/src/addons/mod/forum/pages/discussion/discussion.ts +++ b/src/addons/mod/forum/pages/discussion/discussion.ts @@ -333,20 +333,20 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes * Runs when the page is about to leave and no longer be the active page. */ ionViewWillLeave(): void { - this.syncObserver && this.syncObserver.off(); - this.syncManualObserver && this.syncManualObserver.off(); - this.ratingOfflineObserver && this.ratingOfflineObserver.off(); - this.ratingSyncObserver && this.ratingSyncObserver.off(); - this.changeDiscObserver && this.changeDiscObserver.off(); + this.syncObserver?.off(); + this.syncManualObserver?.off(); + this.ratingOfflineObserver?.off(); + this.ratingSyncObserver?.off(); + this.changeDiscObserver?.off(); delete this.syncObserver; } /** - * Page destroyed. + * @inheritdoc */ ngOnDestroy(): void { - this.onlineObserver && this.onlineObserver.unsubscribe(); - this.discussions && this.discussions.destroy(); + this.onlineObserver?.unsubscribe(); + this.discussions?.destroy(); } /** diff --git a/src/core/components/course-image/course-image.ts b/src/core/components/course-image/course-image.ts index d8459c8c069..9c2253a3646 100644 --- a/src/core/components/course-image/course-image.ts +++ b/src/core/components/course-image/course-image.ts @@ -66,7 +66,7 @@ export class CoreCourseImageComponent { const tint = CoreColors.lighter(course.color, 50); this.element.style.setProperty('--course-color-tint', tint); - } else if(course.colorNumber !== undefined) { + } else if (course.colorNumber !== undefined) { this.element.classList.add('course-color-' + course.colorNumber); } } diff --git a/src/core/directives/long-press.ts b/src/core/directives/long-press.ts index 836ac74bc1b..22dd8058fba 100644 --- a/src/core/directives/long-press.ts +++ b/src/core/directives/long-press.ts @@ -15,8 +15,9 @@ // Based on https://medium.com/madewithply/ionic-4-long-press-gestures-96cf1e44098b import { Directive, ElementRef, OnInit, OnDestroy, Output, EventEmitter } from '@angular/core'; -import { Gesture } from '@ionic/angular'; +import { Gesture, GestureDetail } from '@ionic/angular'; import { GestureController } from '@singletons'; + /** * Directive to add long press actions to html elements. */ @@ -25,13 +26,13 @@ import { GestureController } from '@singletons'; }) export class CoreLongPressDirective implements OnInit, OnDestroy { - readonly HOLD_DURATION = 500; + protected static readonly HOLD_DURATION = 500; element: HTMLElement; pressGesture?: Gesture; timeout?: number; - @Output() longPress = new EventEmitter(); + @Output() longPress = new EventEmitter(); constructor(el: ElementRef) { this.element = el.nativeElement; @@ -52,7 +53,7 @@ export class CoreLongPressDirective implements OnInit, OnDestroy { this.longPress.emit(event); delete this.timeout; - }, this.HOLD_DURATION); + }, CoreLongPressDirective.HOLD_DURATION); }, onMove: () => this.clearTimeout(), onEnd: () => this.clearTimeout(), diff --git a/src/core/features/settings/pages/deviceinfo/deviceinfo.html b/src/core/features/settings/pages/deviceinfo/deviceinfo.html index 1eedc62d59b..abe37a513ec 100644 --- a/src/core/features/settings/pages/deviceinfo/deviceinfo.html +++ b/src/core/features/settings/pages/deviceinfo/deviceinfo.html @@ -103,7 +103,11 @@

{{ 'core.settings.networkstatus' | translate}}

-

{{ 'core.' + deviceInfo.networkStatus | translate }}

+ @if (deviceInfo.isOnline) { +

{{ 'core.online' | translate }}

+ } @else { +

{{ 'core.offline' | translate }}

+ }
diff --git a/src/core/features/settings/pages/deviceinfo/deviceinfo.ts b/src/core/features/settings/pages/deviceinfo/deviceinfo.ts index 6314c3f525b..3974c8ade0c 100644 --- a/src/core/features/settings/pages/deviceinfo/deviceinfo.ts +++ b/src/core/features/settings/pages/deviceinfo/deviceinfo.ts @@ -30,6 +30,7 @@ import { CoreNetwork } from '@services/network'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreSitesFactory } from '@services/sites-factory'; import { CoreText } from '@singletons/text'; +import { GestureDetail } from '@ionic/angular'; /** * Device Info to be shown and copied to clipboard. @@ -51,7 +52,7 @@ interface CoreSettingsDeviceInfo { locationHref?: string; deviceType: string; screen?: string; - networkStatus: string; + isOnline: boolean; wifiConnection: string; cordovaVersion?: string; platform?: string; @@ -93,7 +94,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy { versionCode: CoreConstants.CONFIG.versioncode, compilationTime: CoreConstants.BUILD.compilationTime || 0, lastCommit: CoreConstants.BUILD.lastCommitHash || '', - networkStatus: CoreNetwork.isOnline() ? 'online' : 'offline', + isOnline: CoreNetwork.isOnline(), wifiConnection: CoreNetwork.isWifi() ? 'yes' : 'no', localNotifAvailable: CoreLocalNotifications.isPluginAvailable() ? 'yes' : 'no', pushId: CorePushNotifications.getPushId(), @@ -172,7 +173,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy { this.onlineObserver = CoreNetwork.onChange().subscribe(() => { // Execute the callback in the Angular zone, so change detection doesn't stop working. NgZone.run(() => { - this.deviceInfo.networkStatus = CoreNetwork.isOnline() ? 'online' : 'offline'; + this.deviceInfo.isOnline = CoreNetwork.isOnline(); }); }); @@ -225,8 +226,8 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy { * * @param e Event. */ - copyItemInfo(e: Event): void { - const el = e.target; + copyItemInfo(e: GestureDetail): void { + const el = e.event.target; const text = el?.closest('ion-item')?.textContent?.trim(); text && CoreText.copyToClipboard(text);