MOBILE-4081 chore: Prevent default on scroll controls

This commit is contained in:
Pau Ferrer Ocaña 2022-10-10 16:44:13 +02:00
parent 421627e08e
commit d356bf46fe
4 changed files with 17 additions and 13 deletions

View File

@ -1,9 +1,9 @@
<ion-button fill="clear" (click)="scroll('backward')" [hidden]="scrollPosition === 'hidden'" [disabled]="scrollPosition === 'start'" <ion-button fill="clear" (click)="scroll($event, 'backward')" [hidden]="scrollPosition === 'hidden'" [disabled]="scrollPosition === 'start'"
[attr.aria-label]="'core.scrollbackward' | translate" [attr.aria-controls]="targetId"> [attr.aria-label]="'core.scrollbackward' | translate" [attr.aria-controls]="targetId">
<ion-icon name="fas-chevron-left" slot="icon-only" aria-hidden="true" flip-rtl="false"></ion-icon> <ion-icon name="fas-chevron-left" slot="icon-only" aria-hidden="true" flip-rtl="false"></ion-icon>
</ion-button> </ion-button>
<ion-button fill="clear" (click)="scroll('forward')" [hidden]="scrollPosition === 'hidden'" [disabled]="scrollPosition === 'end'" <ion-button fill="clear" (click)="scroll($event, 'forward')" [hidden]="scrollPosition === 'hidden'" [disabled]="scrollPosition === 'end'"
[attr.aria-label]="'core.scrollforward' | translate" [attr.aria-controls]="targetId"> [attr.aria-label]="'core.scrollforward' | translate" [attr.aria-controls]="targetId">
<ion-icon name="fas-chevron-right" slot="icon-only" aria-hidden="true" flip-rtl="false"></ion-icon> <ion-icon name="fas-chevron-right" slot="icon-only" aria-hidden="true" flip-rtl="false"></ion-icon>
</ion-button> </ion-button>

View File

@ -44,13 +44,17 @@ export class CoreHorizontalScrollControlsComponent {
/** /**
* Scroll the target in the given direction. * Scroll the target in the given direction.
* *
* @param ev Click event
* @param direction Scroll direction. * @param direction Scroll direction.
*/ */
scroll(direction: 'forward' | 'backward'): void { scroll(ev: Event, direction: 'forward' | 'backward'): void {
if (!this.target) { if (!this.target) {
return; return;
} }
ev.stopPropagation();
ev.preventDefault();
const leftDelta = direction === 'forward' ? this.target.clientWidth : -this.target.clientWidth; const leftDelta = direction === 'forward' ? this.target.clientWidth : -this.target.clientWidth;
const newScrollLeft = Math.max( const newScrollLeft = Math.max(
Math.min( Math.min(

View File

@ -163,8 +163,6 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
/** /**
* Open a course. * Open a course.
*
* @param course The course to open.
*/ */
openCourse(): void { openCourse(): void {
if (this.isEnrolled) { if (this.isEnrolled) {
@ -179,6 +177,8 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
/** /**
* Initialize prefetch course. * Initialize prefetch course.
*
* @param forceInit Force initialization of prefetch course info.
*/ */
async initPrefetchCourse(forceInit = false): Promise<void> { async initPrefetchCourse(forceInit = false): Promise<void> {
if (!this.isEnrolled || !this.showDownload || if (!this.isEnrolled || !this.showDownload ||

View File

@ -137,11 +137,11 @@ export class CoreUserProvider {
const result = await site.write<CoreUserUpdatePictureWSResponse>('core_user_update_picture', params); const result = await site.write<CoreUserUpdatePictureWSResponse>('core_user_update_picture', params);
if (!result.success) { if (!result.success || !result.profileimageurl) {
return Promise.reject(null); return Promise.reject(null);
} }
return result.profileimageurl!; return result.profileimageurl;
} }
/** /**
@ -452,7 +452,7 @@ export class CoreUserProvider {
name, name,
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getUserPreferenceCacheKey(params.name!), cacheKey: this.getUserPreferenceCacheKey(name),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES, updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
}; };
@ -613,7 +613,7 @@ export class CoreUserProvider {
const treated: Record<string, boolean> = {}; const treated: Record<string, boolean> = {};
await Promise.all(userIds.map(async (userId) => { await Promise.all(userIds.map(async (userId) => {
if (userId === null) { if (userId === null || !siteId) {
return; return;
} }
@ -630,7 +630,7 @@ export class CoreUserProvider {
const profile = await this.getProfile(userId, courseId, false, siteId); const profile = await this.getProfile(userId, courseId, false, siteId);
if (profile.profileimageurl) { if (profile.profileimageurl) {
await CoreFilepool.addToQueueByUrl(siteId!, profile.profileimageurl); await CoreFilepool.addToQueueByUrl(siteId, profile.profileimageurl);
} }
} catch (error) { } catch (error) {
this.logger.warn(`Ignore error when prefetching user ${userId}`, error); this.logger.warn(`Ignore error when prefetching user ${userId}`, error);
@ -658,7 +658,7 @@ export class CoreUserProvider {
const promises = entries.map(async (entry) => { const promises = entries.map(async (entry) => {
const imageUrl = <string> entry[propertyName]; const imageUrl = <string> entry[propertyName];
if (!imageUrl || treated[imageUrl]) { if (!imageUrl || treated[imageUrl] || !siteId) {
// It doesn't have an image or it has already been treated. // It doesn't have an image or it has already been treated.
return; return;
} }
@ -666,7 +666,7 @@ export class CoreUserProvider {
treated[imageUrl] = true; treated[imageUrl] = true;
try { try {
await CoreFilepool.addToQueueByUrl(siteId!, imageUrl); await CoreFilepool.addToQueueByUrl(siteId, imageUrl);
} catch (ex) { } catch (ex) {
this.logger.warn(`Ignore error when prefetching user avatar ${imageUrl}`, entry, ex); this.logger.warn(`Ignore error when prefetching user avatar ${imageUrl}`, entry, ex);
} }
@ -682,7 +682,7 @@ export class CoreUserProvider {
* @param search The string to search. * @param search The string to search.
* @param searchAnywhere Whether to find a match anywhere or only at the beginning. * @param searchAnywhere Whether to find a match anywhere or only at the beginning.
* @param page Page to get. * @param page Page to get.
* @param limitNumber Number of participants to get. * @param perPage Number of participants to get.
* @param siteId Site Id. If not defined, use current site. * @param siteId Site Id. If not defined, use current site.
* @return Promise resolved when the participants are retrieved. * @return Promise resolved when the participants are retrieved.
* @since 3.8 * @since 3.8