Skip to content

Commit

Permalink
Merge pull request #4303 from crazyserver/MOBILE-4653
Browse files Browse the repository at this point in the history
Mobile 4653
  • Loading branch information
dpalou authored Jan 30, 2025
2 parents ba81d76 + a534527 commit d12e2df
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
10 changes: 6 additions & 4 deletions src/addons/blog/pages/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
return this.fetchEntries(false).finally(() => {
infiniteComplete && infiniteComplete();
});
async loadMore(infiniteComplete?: () => void): Promise<void> {
try {
return await this.fetchEntries(false);
} finally {
infiniteComplete?.();
}
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/addons/mod/forum/pages/discussion/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/course-image/course-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/core/directives/long-press.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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<GestureDetail>();

constructor(el: ElementRef) {
this.element = el.nativeElement;
Expand All @@ -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(),
Expand Down
6 changes: 5 additions & 1 deletion src/core/features/settings/pages/deviceinfo/deviceinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ <h1>
<ion-item (longPress)="copyItemInfo($event)">
<ion-label class="ion-text-wrap">
<p class="item-heading">{{ 'core.settings.networkstatus' | translate}}</p>
<p>{{ 'core.' + deviceInfo.networkStatus | translate }}</p>
@if (deviceInfo.isOnline) {
<p>{{ 'core.online' | translate }}</p>
} @else {
<p>{{ 'core.offline' | translate }}</p>
}
</ion-label>
</ion-item>
<ion-item (longPress)="copyItemInfo($event)">
Expand Down
11 changes: 6 additions & 5 deletions src/core/features/settings/pages/deviceinfo/deviceinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -51,7 +52,7 @@ interface CoreSettingsDeviceInfo {
locationHref?: string;
deviceType: string;
screen?: string;
networkStatus: string;
isOnline: boolean;
wifiConnection: string;
cordovaVersion?: string;
platform?: string;
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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();
});
});

Expand Down Expand Up @@ -225,8 +226,8 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
*
* @param e Event.
*/
copyItemInfo(e: Event): void {
const el = <Element>e.target;
copyItemInfo(e: GestureDetail): void {
const el = <Element>e.event.target;
const text = el?.closest('ion-item')?.textContent?.trim();

text && CoreText.copyToClipboard(text);
Expand Down

0 comments on commit d12e2df

Please sign in to comment.