forked from CIT/Vmeda.Online
		
	Merge pull request #2732 from dpalou/MOBILE-3623
MOBILE-3623 plugins: Wait to display success message if goBackOnSuccess
This commit is contained in:
		
						commit
						0eab7f5bef
					
				@ -74,7 +74,8 @@ export class CoreSitePluginsCallWSBaseDirective implements OnInit, OnDestroy {
 | 
			
		||||
 | 
			
		||||
            this.onSuccess.emit(result);
 | 
			
		||||
 | 
			
		||||
            return this.wsCallSuccess(result);
 | 
			
		||||
            // Don't block the promise with the success function.
 | 
			
		||||
            this.wsCallSuccess(result);
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
            this.onError.emit(error);
 | 
			
		||||
            this.logger.error(`Error calling WS ${this.name}`, error);
 | 
			
		||||
@ -108,9 +109,10 @@ export class CoreSitePluginsCallWSBaseDirective implements OnInit, OnDestroy {
 | 
			
		||||
     * Function called when the WS call is successful.
 | 
			
		||||
     *
 | 
			
		||||
     * @param result Result of the WS call.
 | 
			
		||||
     * @return If async, promise resolved when done.
 | 
			
		||||
     */
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
			
		||||
    protected wsCallSuccess(result: unknown): void {
 | 
			
		||||
    protected wsCallSuccess(result: unknown): void | Promise<void> {
 | 
			
		||||
        // Function to be overridden.
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -65,17 +65,17 @@ export class CoreSitePluginsCallWSDirective extends CoreSitePluginsCallWSOnClick
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    protected wsCallSuccess(): void {
 | 
			
		||||
    protected async wsCallSuccess(): Promise<void> {
 | 
			
		||||
        if (CoreUtils.isTrueOrOne(this.goBackOnSuccess)) {
 | 
			
		||||
            await CoreNavigator.back();
 | 
			
		||||
        } else if (CoreUtils.isTrueOrOne(this.refreshOnSuccess) && this.parentContent) {
 | 
			
		||||
            this.parentContent.refreshContent(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (typeof this.successMessage != 'undefined') {
 | 
			
		||||
            // Display the success message.
 | 
			
		||||
            CoreDomUtils.showToast(this.successMessage || Translate.instant('core.success'));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (CoreUtils.isTrueOrOne(this.goBackOnSuccess)) {
 | 
			
		||||
            CoreNavigator.back();
 | 
			
		||||
        } else if (CoreUtils.isTrueOrOne(this.refreshOnSuccess) && this.parentContent) {
 | 
			
		||||
            this.parentContent.refreshContent(true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user