@@ -30,6 +30,7 @@ import { CoreConfig } from '@services/config';
3030import { CoreEvents } from '@singletons/events' ;
3131import { CoreColors } from './colors' ;
3232import { CorePrompts } from '@services/overlays/prompts' ;
33+ import { CoreNativeCordovaPluginResultStatus } from '@features/native/constants' ;
3334
3435/**
3536 * Singleton with helper functions to handler open files and urls.
@@ -124,18 +125,27 @@ export class CoreOpener {
124125 // Error, use the original path.
125126 }
126127
127- const openFile = async ( path : string , mimetype ?: string ) => {
128+ const openFile = async ( path : string , mimetype ?: string , hasFailed ?: boolean ) => {
128129 try {
129130 if ( CoreOpener . shouldOpenWithDialog ( options ) ) {
130131 await FileOpener . showOpenWithDialog ( path , mimetype || '' ) ;
131132 } else {
132133 await FileOpener . open ( path , mimetype || '' ) ;
133134 }
134135 } catch ( error ) {
136+ if (
137+ hasFailed ||
138+ error . status !== CoreNativeCordovaPluginResultStatus . ERROR ||
139+ error . message . includes ( 'Activity not found' )
140+ ) {
141+ throw error ;
142+ }
143+
135144 // If the file contains the % character without encoding the open can fail. Try again encoding it.
136145 const encodedPath = encodeURI ( path ) ;
146+
137147 if ( path !== encodedPath ) {
138- return await openFile ( encodedPath , mimetype ) ;
148+ return await openFile ( encodedPath , mimetype , true ) ;
139149 }
140150
141151 throw error ;
0 commit comments