MOBILE-4579 notifications: Avoid showing user avatar from customdata

main
Pau Ferrer Ocaña 2024-04-24 16:27:57 +02:00
parent d0c0b83296
commit 33d6d169f9
3 changed files with 11 additions and 5 deletions

View File

@ -34,13 +34,14 @@
img {
width: var(--icon-size);
height: var(--icon-size);
padding: 4px;
}
ion-icon {
font-size: var(--icon-size);
}
padding: 0px;
background: var(--background-color);
border-radius: var(--mdl-shape-borderRadius-xs);
border-radius: var(--core-avatar-radius);
@include margin(6px, 8px, 6px, 0px);
}

View File

@ -119,7 +119,7 @@ export class AddonNotificationsProvider {
notification.notif = 1;
notification.read = notification.timeread > 0;
if (typeof notification.customdata == 'string') {
if (typeof notification.customdata === 'string') {
notification.customdata = CoreTextUtils.parseJSON<Record<string, string|number>>(notification.customdata, {});
}
@ -142,9 +142,6 @@ export class AddonNotificationsProvider {
}
}
const imgUrl = notification.customdata?.notificationpictureurl || notification.customdata?.notificationiconurl;
notification.imgUrl = imgUrl ? String(imgUrl) : undefined;
if (notification.useridfrom > 0) {
// Try to get the profile picture of the user.
try {
@ -155,6 +152,12 @@ export class AddonNotificationsProvider {
} catch {
// Error getting user. This can happen if device is offline or the user is deleted.
}
} else {
// Do not assign avatar for newlogin notifications.
if (notification.eventtype !== 'newlogin') {
const imgUrl = notification.customdata?.notificationpictureurl || notification.customdata?.notificationiconurl;
notification.imgUrl = imgUrl ? String(imgUrl) : undefined;
}
}
return notification;

View File

@ -79,6 +79,8 @@
font-weight: normal;
width: calc(var(--core-avatar-size) - var(--userpicture-padding) - var(--userpicture-padding));
height: calc(var(--core-avatar-size) - var(--userpicture-padding) - var(--userpicture-padding));
min-height: 0px;
min-width: 0px;
font-size: calc(var(--core-avatar-size)*0.3);
margin: var(--userpicture-padding);