Skip to content

Commit d12e2df

Browse files
authored
Merge pull request #4303 from crazyserver/MOBILE-4653
Mobile 4653
2 parents ba81d76 + a534527 commit d12e2df

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

src/addons/blog/pages/index/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,12 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy {
363363
* @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading.
364364
* @returns Resolved when done.
365365
*/
366-
loadMore(infiniteComplete?: () => void): Promise<void> {
367-
return this.fetchEntries(false).finally(() => {
368-
infiniteComplete && infiniteComplete();
369-
});
366+
async loadMore(infiniteComplete?: () => void): Promise<void> {
367+
try {
368+
return await this.fetchEntries(false);
369+
} finally {
370+
infiniteComplete?.();
371+
}
370372
}
371373

372374
/**

src/addons/mod/forum/pages/discussion/discussion.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,20 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
333333
* Runs when the page is about to leave and no longer be the active page.
334334
*/
335335
ionViewWillLeave(): void {
336-
this.syncObserver && this.syncObserver.off();
337-
this.syncManualObserver && this.syncManualObserver.off();
338-
this.ratingOfflineObserver && this.ratingOfflineObserver.off();
339-
this.ratingSyncObserver && this.ratingSyncObserver.off();
340-
this.changeDiscObserver && this.changeDiscObserver.off();
336+
this.syncObserver?.off();
337+
this.syncManualObserver?.off();
338+
this.ratingOfflineObserver?.off();
339+
this.ratingSyncObserver?.off();
340+
this.changeDiscObserver?.off();
341341
delete this.syncObserver;
342342
}
343343

344344
/**
345-
* Page destroyed.
345+
* @inheritdoc
346346
*/
347347
ngOnDestroy(): void {
348-
this.onlineObserver && this.onlineObserver.unsubscribe();
349-
this.discussions && this.discussions.destroy();
348+
this.onlineObserver?.unsubscribe();
349+
this.discussions?.destroy();
350350
}
351351

352352
/**

src/core/components/course-image/course-image.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class CoreCourseImageComponent {
6666

6767
const tint = CoreColors.lighter(course.color, 50);
6868
this.element.style.setProperty('--course-color-tint', tint);
69-
} else if(course.colorNumber !== undefined) {
69+
} else if (course.colorNumber !== undefined) {
7070
this.element.classList.add('course-color-' + course.colorNumber);
7171
}
7272
}

src/core/directives/long-press.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
// Based on https://medium.com/madewithply/ionic-4-long-press-gestures-96cf1e44098b
1616

1717
import { Directive, ElementRef, OnInit, OnDestroy, Output, EventEmitter } from '@angular/core';
18-
import { Gesture } from '@ionic/angular';
18+
import { Gesture, GestureDetail } from '@ionic/angular';
1919
import { GestureController } from '@singletons';
20+
2021
/**
2122
* Directive to add long press actions to html elements.
2223
*/
@@ -25,13 +26,13 @@ import { GestureController } from '@singletons';
2526
})
2627
export class CoreLongPressDirective implements OnInit, OnDestroy {
2728

28-
readonly HOLD_DURATION = 500;
29+
protected static readonly HOLD_DURATION = 500;
2930

3031
element: HTMLElement;
3132
pressGesture?: Gesture;
3233
timeout?: number;
3334

34-
@Output() longPress = new EventEmitter();
35+
@Output() longPress = new EventEmitter<GestureDetail>();
3536

3637
constructor(el: ElementRef) {
3738
this.element = el.nativeElement;
@@ -52,7 +53,7 @@ export class CoreLongPressDirective implements OnInit, OnDestroy {
5253
this.longPress.emit(event);
5354

5455
delete this.timeout;
55-
}, this.HOLD_DURATION);
56+
}, CoreLongPressDirective.HOLD_DURATION);
5657
},
5758
onMove: () => this.clearTimeout(),
5859
onEnd: () => this.clearTimeout(),

src/core/features/settings/pages/deviceinfo/deviceinfo.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ <h1>
103103
<ion-item (longPress)="copyItemInfo($event)">
104104
<ion-label class="ion-text-wrap">
105105
<p class="item-heading">{{ 'core.settings.networkstatus' | translate}}</p>
106-
<p>{{ 'core.' + deviceInfo.networkStatus | translate }}</p>
106+
@if (deviceInfo.isOnline) {
107+
<p>{{ 'core.online' | translate }}</p>
108+
} @else {
109+
<p>{{ 'core.offline' | translate }}</p>
110+
}
107111
</ion-label>
108112
</ion-item>
109113
<ion-item (longPress)="copyItemInfo($event)">

src/core/features/settings/pages/deviceinfo/deviceinfo.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { CoreNetwork } from '@services/network';
3030
import { CoreLoginHelper } from '@features/login/services/login-helper';
3131
import { CoreSitesFactory } from '@services/sites-factory';
3232
import { CoreText } from '@singletons/text';
33+
import { GestureDetail } from '@ionic/angular';
3334

3435
/**
3536
* Device Info to be shown and copied to clipboard.
@@ -51,7 +52,7 @@ interface CoreSettingsDeviceInfo {
5152
locationHref?: string;
5253
deviceType: string;
5354
screen?: string;
54-
networkStatus: string;
55+
isOnline: boolean;
5556
wifiConnection: string;
5657
cordovaVersion?: string;
5758
platform?: string;
@@ -93,7 +94,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
9394
versionCode: CoreConstants.CONFIG.versioncode,
9495
compilationTime: CoreConstants.BUILD.compilationTime || 0,
9596
lastCommit: CoreConstants.BUILD.lastCommitHash || '',
96-
networkStatus: CoreNetwork.isOnline() ? 'online' : 'offline',
97+
isOnline: CoreNetwork.isOnline(),
9798
wifiConnection: CoreNetwork.isWifi() ? 'yes' : 'no',
9899
localNotifAvailable: CoreLocalNotifications.isPluginAvailable() ? 'yes' : 'no',
99100
pushId: CorePushNotifications.getPushId(),
@@ -172,7 +173,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
172173
this.onlineObserver = CoreNetwork.onChange().subscribe(() => {
173174
// Execute the callback in the Angular zone, so change detection doesn't stop working.
174175
NgZone.run(() => {
175-
this.deviceInfo.networkStatus = CoreNetwork.isOnline() ? 'online' : 'offline';
176+
this.deviceInfo.isOnline = CoreNetwork.isOnline();
176177
});
177178
});
178179

@@ -225,8 +226,8 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
225226
*
226227
* @param e Event.
227228
*/
228-
copyItemInfo(e: Event): void {
229-
const el = <Element>e.target;
229+
copyItemInfo(e: GestureDetail): void {
230+
const el = <Element>e.event.target;
230231
const text = el?.closest('ion-item')?.textContent?.trim();
231232

232233
text && CoreText.copyToClipboard(text);

0 commit comments

Comments
 (0)