|
14 | 14 |
|
15 | 15 | import { Injectable } from '@angular/core'; |
16 | 16 | import { CoreEventsProvider } from '@providers/events'; |
| 17 | +import { CoreTextUtils } from '@providers/utils/text'; |
17 | 18 | import { CoreUtilsProvider } from '@providers/utils/utils'; |
18 | 19 | import { CorePushNotificationsClickHandler } from '@core/pushnotifications/providers/delegate'; |
19 | 20 | import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; |
@@ -60,38 +61,35 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications |
60 | 61 | * @param notification The notification to check. |
61 | 62 | * @return Promise resolved when done. |
62 | 63 | */ |
63 | | - handleClick(notification: any): Promise<any> { |
64 | | - let promise; |
| 64 | + async handleClick(notification: any): Promise<void> { |
| 65 | + |
| 66 | + if (notification.customdata.extendedtext) { |
| 67 | + // Display the text in a modal. |
| 68 | + return CoreTextUtils.instance.viewText(notification.title, notification.customdata.extendedtext, { |
| 69 | + displayCopyButton: true, |
| 70 | + modalOptions: { cssClass: 'core-modal-fullscreen' }, |
| 71 | + }); |
| 72 | + } |
65 | 73 |
|
66 | 74 | // Try to handle the appurl first. |
67 | 75 | if (notification.customdata && notification.customdata.appurl) { |
68 | | - promise = this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true); |
69 | | - } else { |
70 | | - promise = Promise.resolve(false); |
| 76 | + if (this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true)) { |
| 77 | + // Link treated, stop. |
| 78 | + return; |
| 79 | + } |
71 | 80 | } |
72 | 81 |
|
73 | | - return promise.then((treated) => { |
74 | | - |
75 | | - if (!treated) { |
76 | | - // No link or cannot be handled by the app. Try to handle the contexturl now. |
77 | | - if (notification.contexturl) { |
78 | | - return this.linkHelper.handleLink(notification.contexturl); |
79 | | - } else { |
80 | | - return false; |
81 | | - } |
| 82 | + // No appurl or cannot be handled by the app. Try to handle the contexturl now. |
| 83 | + if (notification.contexturl) { |
| 84 | + if (this.linkHelper.handleLink(notification.contexturl)) { |
| 85 | + // Link treated, stop. |
| 86 | + return; |
82 | 87 | } |
| 88 | + } |
83 | 89 |
|
84 | | - return true; |
85 | | - }).then((treated) => { |
| 90 | + // No contexturl or cannot be handled by the app. Open the notifications page. |
| 91 | + await this.utils.ignoreErrors(this.notificationsProvider.invalidateNotificationsList(notification.site)); |
86 | 92 |
|
87 | | - if (!treated) { |
88 | | - // No link or cannot be handled by the app. Open the notifications page. |
89 | | - return this.notificationsProvider.invalidateNotificationsList(notification.site).catch(() => { |
90 | | - // Ignore errors. |
91 | | - }).then(() => { |
92 | | - return this.linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site); |
93 | | - }); |
94 | | - } |
95 | | - }); |
| 93 | + await this.linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site); |
96 | 94 | } |
97 | 95 | } |
0 commit comments