Merge pull request #2981 from dpalou/MOBILE-3828

Mobile 3828
main
Noel De Martin 2021-11-02 13:01:16 +01:00 committed by GitHub
commit 5a1bcb8380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 33 deletions

View File

@ -1,3 +1,5 @@
@import "~theme/globals";
:host {
.core-notification-icon {
width: 34px;
@ -17,11 +19,17 @@
.header {
background-color: var(--gray-lighter);
}
.picture {
width: auto;
text-align: center;
.picture {
width: 48px;
text-align: center;
@include padding-horizontal(4px, 0px);
padding-top: 8px;
img {
width: 44px !important;
}
}
}
.subject {

View File

@ -48,7 +48,7 @@
<ion-item class="ion-text-wrap">
<ion-label>
<core-format-text [text]="notification.mobiletext | coreCreateLinks" contextLevel="system"
[contextInstanceId]="0" [maxHeight]="notification.displayfullhtml ? 120 : null">
[contextInstanceId]="0" [maxHeight]="120">
</core-format-text>
</ion-label>
</ion-item>

View File

@ -36,7 +36,7 @@ import {
@Component({
selector: 'page-addon-notifications-list',
templateUrl: 'list.html',
styleUrls: ['list.scss'],
styleUrls: ['../../notifications.scss'],
})
export class AddonNotificationsListPage implements OnInit, OnDestroy {

View File

@ -29,6 +29,7 @@ import { CoreUtils } from '@services/utils/utils';
@Component({
selector: 'page-addon-notifications-notification',
templateUrl: 'notification.html',
styleUrls: ['../../notifications.scss'],
})
export class AddonNotificationsNotificationPage implements OnInit {

View File

@ -25,7 +25,6 @@ import {
AddonNotificationsPreferencesNotificationProcessor,
AddonNotificationsPreferencesProcessor,
} from './notifications';
import { CoreTextUtils } from '@services/utils/text';
/**
* Service that provides some helper functions for notifications.
@ -42,13 +41,8 @@ export class AddonNotificationsHelperProvider {
notification: AddonNotificationsNotificationMessageFormatted,
): AddonNotificationsNotificationToRender {
const formattedNotification: AddonNotificationsNotificationToRender = notification;
formattedNotification.displayfullhtml = this.shouldDisplayFullHtml(notification);
formattedNotification.iconurl = formattedNotification.iconurl || undefined; // Make sure the property exists.
formattedNotification.mobiletext = formattedNotification.displayfullhtml ?
notification.fullmessagehtml :
CoreTextUtils.replaceNewLines((formattedNotification.mobiletext || '').replace(/-{4,}/ig, ''), '<br>');
return formattedNotification;
}
@ -140,16 +134,6 @@ export class AddonNotificationsHelperProvider {
return result;
}
/**
* Check whether we should display full HTML of the notification.
*
* @param notification Notification.
* @return Whether to display full HTML.
*/
protected shouldDisplayFullHtml(notification: AddonNotificationsNotificationToRender): boolean {
return notification.component == 'mod_forum' && notification.eventtype == 'digests';
}
}
export const AddonNotificationsHelper = makeSingleton(AddonNotificationsHelperProvider);
@ -187,6 +171,5 @@ export type AddonNotificationsPreferencesProcessorFormatted = AddonNotifications
* Notification with some calculated data to render it.
*/
export type AddonNotificationsNotificationToRender = AddonNotificationsNotificationMessageFormatted & {
displayfullhtml?: boolean; // Whether to display the full HTML of the notification.
iconurl?: string;
};

View File

@ -56,13 +56,7 @@ export class AddonNotificationsProvider {
const promises = notifications.map(async (notificationRaw) => {
const notification = <AddonNotificationsNotificationMessageFormatted> notificationRaw;
// Set message to show.
if (notification.component && notification.component == 'mod_forum') {
notification.mobiletext = notification.smallmessage;
} else {
notification.mobiletext = notification.fullmessage;
}
notification.mobiletext = notification.fullmessagehtml || notification.fullmessage || notification.smallmessage;
notification.moodlecomponent = notification.component;
notification.notification = 1;
notification.notif = 1;
@ -171,7 +165,7 @@ export class AddonNotificationsProvider {
// Request 1 more notification so we can know if there are more notifications.
const originalLimit = options.limit;
options.limit + 1;
options.limit = options.limit + 1;
const site = await CoreSites.getSite(options.siteId);

View File

@ -166,8 +166,8 @@ export class CoreFormatTextDirective implements OnChanges {
const originalWidth = img.attributes.getNamedItem('width');
const forcedWidth = Number(originalWidth?.value);
if (!isNaN(forcedWidth)) {
if (originalWidth!.value.indexOf('%') < 0) {
if (originalWidth && !isNaN(forcedWidth)) {
if (originalWidth.value.indexOf('%') < 0) {
img.style.width = forcedWidth + 'px';
} else {
img.style.width = forcedWidth + '%';