forked from EVOgeek/Vmeda.Online
		
	
						commit
						72baa77fc0
					
				@ -14,6 +14,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { Injectable } from '@angular/core';
 | 
					import { Injectable } from '@angular/core';
 | 
				
			||||||
import { CoreEventsProvider } from '@providers/events';
 | 
					import { CoreEventsProvider } from '@providers/events';
 | 
				
			||||||
 | 
					import { CoreTextUtils } from '@providers/utils/text';
 | 
				
			||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
 | 
					import { CoreUtilsProvider } from '@providers/utils/utils';
 | 
				
			||||||
import { CorePushNotificationsClickHandler } from '@core/pushnotifications/providers/delegate';
 | 
					import { CorePushNotificationsClickHandler } from '@core/pushnotifications/providers/delegate';
 | 
				
			||||||
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
 | 
					import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
 | 
				
			||||||
@ -60,38 +61,46 @@ export class AddonNotificationsPushClickHandler implements CorePushNotifications
 | 
				
			|||||||
     * @param notification The notification to check.
 | 
					     * @param notification The notification to check.
 | 
				
			||||||
     * @return Promise resolved when done.
 | 
					     * @return Promise resolved when done.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    handleClick(notification: any): Promise<any> {
 | 
					    async handleClick(notification: any): Promise<void> {
 | 
				
			||||||
        let promise;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Try to handle the appurl first.
 | 
					        if (notification.customdata.extendedtext) {
 | 
				
			||||||
 | 
					            // Display the text in a modal.
 | 
				
			||||||
 | 
					            return CoreTextUtils.instance.viewText(notification.title, notification.customdata.extendedtext, {
 | 
				
			||||||
 | 
					                displayCopyButton: true,
 | 
				
			||||||
 | 
					                modalOptions: { cssClass: 'core-modal-fullscreen' },
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Try to handle the appurl.
 | 
				
			||||||
        if (notification.customdata && notification.customdata.appurl) {
 | 
					        if (notification.customdata && notification.customdata.appurl) {
 | 
				
			||||||
            promise = this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true);
 | 
					            switch (notification.customdata.appurlopenin) {
 | 
				
			||||||
        } else {
 | 
					                case 'inappbrowser':
 | 
				
			||||||
            promise = Promise.resolve(false);
 | 
					                    this.utils.openInApp(notification.customdata.appurl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                case 'browser':
 | 
				
			||||||
 | 
					                    return this.utils.openInBrowser(notification.customdata.appurl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                    if (this.linkHelper.handleLink(notification.customdata.appurl, undefined, undefined, true)) {
 | 
				
			||||||
 | 
					                        // Link treated, stop.
 | 
				
			||||||
 | 
					                        return;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return promise.then((treated) => {
 | 
					        // No appurl or cannot be handled by the app. Try to handle the contexturl now.
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (!treated) {
 | 
					 | 
				
			||||||
                // No link or cannot be handled by the app. Try to handle the contexturl now.
 | 
					 | 
				
			||||||
        if (notification.contexturl) {
 | 
					        if (notification.contexturl) {
 | 
				
			||||||
                    return this.linkHelper.handleLink(notification.contexturl);
 | 
					            if (this.linkHelper.handleLink(notification.contexturl)) {
 | 
				
			||||||
                } else {
 | 
					                // Link treated, stop.
 | 
				
			||||||
                    return false;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return true;
 | 
					        // No contexturl or cannot be handled by the app. Open the notifications page.
 | 
				
			||||||
        }).then((treated) => {
 | 
					        await this.utils.ignoreErrors(this.notificationsProvider.invalidateNotificationsList(notification.site));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!treated) {
 | 
					        await this.linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site);
 | 
				
			||||||
                // No link or cannot be handled by the app. Open the notifications page.
 | 
					 | 
				
			||||||
                return this.notificationsProvider.invalidateNotificationsList(notification.site).catch(() => {
 | 
					 | 
				
			||||||
                    // Ignore errors.
 | 
					 | 
				
			||||||
                }).then(() => {
 | 
					 | 
				
			||||||
                    return this.linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site);
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -527,6 +527,12 @@ export class CorePushNotificationsProvider {
 | 
				
			|||||||
                            localNotif.icon = notification.image;
 | 
					                            localNotif.icon = notification.image;
 | 
				
			||||||
                            // This feature isn't supported by the official plugin, we use a fork.
 | 
					                            // This feature isn't supported by the official plugin, we use a fork.
 | 
				
			||||||
                            (<any> localNotif).iconType = data['image-type'];
 | 
					                            (<any> localNotif).iconType = data['image-type'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            localNotif.summary = data.summaryText;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (data.picture) {
 | 
				
			||||||
 | 
					                                localNotif.attachments = [data.picture];
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        Promise.all(promises).then(() => {
 | 
					                        Promise.all(promises).then(() => {
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { Injectable } from '@angular/core';
 | 
					import { Injectable } from '@angular/core';
 | 
				
			||||||
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
 | 
					import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
 | 
				
			||||||
import { ModalController } from 'ionic-angular';
 | 
					import { ModalController, ModalOptions } from 'ionic-angular';
 | 
				
			||||||
import { TranslateService } from '@ngx-translate/core';
 | 
					import { TranslateService } from '@ngx-translate/core';
 | 
				
			||||||
import { CoreLangProvider } from '../lang';
 | 
					import { CoreLangProvider } from '../lang';
 | 
				
			||||||
import { makeSingleton } from '@singletons/core.singletons';
 | 
					import { makeSingleton } from '@singletons/core.singletons';
 | 
				
			||||||
@ -1163,7 +1163,7 @@ export class CoreTextUtilsProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            Object.assign(params, options);
 | 
					            Object.assign(params, options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const modal = this.modalCtrl.create('CoreViewerTextPage', params);
 | 
					            const modal = this.modalCtrl.create('CoreViewerTextPage', params, options.modalOptions);
 | 
				
			||||||
            modal.present();
 | 
					            modal.present();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1181,6 +1181,7 @@ export type CoreTextUtilsViewTextOptions = {
 | 
				
			|||||||
    instanceId?: number; // The instance ID related to the context.
 | 
					    instanceId?: number; // The instance ID related to the context.
 | 
				
			||||||
    courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
 | 
					    courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters.
 | 
				
			||||||
    displayCopyButton?: boolean; // Whether to display a button to copy the text.
 | 
					    displayCopyButton?: boolean; // Whether to display a button to copy the text.
 | 
				
			||||||
 | 
					    modalOptions?: ModalOptions; // Modal options.
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class CoreTextUtils extends makeSingleton(CoreTextUtilsProvider) {}
 | 
					export class CoreTextUtils extends makeSingleton(CoreTextUtilsProvider) {}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user