MOBILE-4362 url: Use isThemeImageUrl function when needed
parent
bfaadfbb8c
commit
79300ba408
|
@ -20,8 +20,8 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
|||
import { USER_PROFILE_PICTURE_UPDATED, CoreUserBasicData } from '@features/user/services/user';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreNetwork } from '@services/network';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUserHelper } from '@features/user/services/user-helper';
|
||||
import { CoreUrlUtils } from '@services/utils/url';
|
||||
|
||||
/**
|
||||
* Component to display a "user avatar".
|
||||
|
@ -111,7 +111,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.initials = CoreUserHelper.getUserInitials(this.user);
|
||||
}
|
||||
|
||||
if (this.initials && this.avatarUrl && CoreUrl.parse(this.avatarUrl)?.path?.startsWith('/theme/image.php')) {
|
||||
if (this.initials && this.avatarUrl && CoreUrlUtils.isThemeImageUrl(this.avatarUrl)) {
|
||||
this.avatarUrl = undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import { makeSingleton, Translate } from '@singletons';
|
|||
import { CoreQuestion, CoreQuestionProvider, CoreQuestionQuestionParsed, CoreQuestionsAnswers } from './question';
|
||||
import { CoreQuestionDelegate } from './question-delegate';
|
||||
import { CoreIcons } from '@singletons/icons';
|
||||
import { CoreUrlUtils } from '@services/utils/url';
|
||||
|
||||
/**
|
||||
* Service with some common functions to handle questions.
|
||||
|
@ -678,7 +679,7 @@ export class CoreQuestionHelperProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
if (fileUrl.indexOf('theme/image.php') > -1 && fileUrl.indexOf('flagged') > -1) {
|
||||
if (CoreUrlUtils.isThemeImageUrl(fileUrl) && fileUrl.indexOf('flagged') > -1) {
|
||||
// Ignore flag images.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import { CoreSite } from '@classes/site';
|
|||
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
|
||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreUrlUtils } from '@services/utils/url';
|
||||
|
||||
/**
|
||||
* Page that displays info about a user.
|
||||
|
@ -247,7 +248,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy {
|
|||
return 'undefined';
|
||||
}
|
||||
|
||||
if (avatarUrl.startsWith(`${this.site?.siteUrl}/theme/image.php`)) {
|
||||
if (CoreUrlUtils.isThemeImageUrl(avatarUrl, this.site?.siteUrl)) {
|
||||
return 'default';
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import { CoreStatusWithWarningsWSResponse, CoreWSExternalWarning } from '@servic
|
|||
import { CoreError } from '@classes/errors/error';
|
||||
import { USERS_TABLE_NAME, CoreUserDBRecord } from './database/user';
|
||||
import { CoreUserHelper } from './user-helper';
|
||||
import { CoreUrl } from '@singletons/url';
|
||||
import { CoreUrlUtils } from '@services/utils/url';
|
||||
|
||||
const ROOT_CACHE_KEY = 'mmUser:';
|
||||
|
||||
|
@ -671,7 +671,7 @@ export class CoreUserProvider {
|
|||
// Do not prefetch when initials are set and image is default.
|
||||
if ('firstname' in entry || 'lastname' in entry) {
|
||||
const initials = CoreUserHelper.getUserInitials(entry);
|
||||
if (initials && imageUrl && CoreUrl.parse(imageUrl)?.path === '/theme/image.php') {
|
||||
if (initials && imageUrl && CoreUrlUtils.isThemeImageUrl(imageUrl)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -493,11 +493,16 @@ export class CoreUrlUtilsProvider {
|
|||
/**
|
||||
* Returns if a URL is a theme image URL.
|
||||
*
|
||||
* @param url The URL to test.
|
||||
* @param imageUrl The URL to test.
|
||||
* @param siteUrl The Site Url.
|
||||
* @returns Whether the URL is a theme image URL.
|
||||
*/
|
||||
isThemeImageUrl(url: string): boolean {
|
||||
return url?.indexOf('/theme/image.php') !== -1;
|
||||
isThemeImageUrl(imageUrl: string, siteUrl?: string): boolean {
|
||||
if (siteUrl) {
|
||||
return imageUrl.startsWith(`${siteUrl}/theme/image.php`);
|
||||
}
|
||||
|
||||
return imageUrl?.indexOf('/theme/image.php') !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue