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 #4303

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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