diff --git a/src/components/Apps/AppViewer.tsx b/src/components/Apps/AppViewer.tsx index a2a5225..7304b3c 100644 --- a/src/components/Apps/AppViewer.tsx +++ b/src/components/Apps/AppViewer.tsx @@ -53,7 +53,7 @@ export const AppViewer = React.forwardRef(({ app , hide}, iframeRef) => { // Signal non-manual navigation iframeRef.current.contentWindow.postMessage( - { action: 'PERFORMING_NON_MANUAL' }, '*' + { action: 'PERFORMING_NON_MANUAL', currentIndex: previousPageIndex }, '*' ); console.log('previousPageIndex', previousPageIndex) // Update the current index locally @@ -88,10 +88,8 @@ export const AppViewer = React.forwardRef(({ app , hide}, iframeRef) => { await navigationPromise; console.log('Navigation succeeded within 200ms.'); } catch (error) { - iframeRef.current.contentWindow.postMessage( - { action: 'PERFORMING_NON_MANUAL' }, '*' - ); - setUrl(`${getBaseApiReact()}/render/${app?.service}/${app?.name}${app?.previousPath != null ? previousPath : ''}?theme=dark&identifier=${(app?.identifier != null && app?.identifier != 'null') ? app?.identifier : ''}&time=${new Date().getMilliseconds()}&isManualNavigation=false`) + + setUrl(`${getBaseApiReact()}/render/${app?.service}/${app?.name}${previousPath != null ? previousPath : ''}?theme=dark&identifier=${(app?.identifier != null && app?.identifier != 'null') ? app?.identifier : ''}&time=${new Date().getMilliseconds()}&isManualNavigation=false`) // iframeRef.current.contentWindow.location.href = previousPath; // Fallback URL update } } else { diff --git a/src/components/Apps/useQortalMessageListener.tsx b/src/components/Apps/useQortalMessageListener.tsx index 11e1680..bf99e31 100644 --- a/src/components/Apps/useQortalMessageListener.tsx +++ b/src/components/Apps/useQortalMessageListener.tsx @@ -426,15 +426,13 @@ isDOMContentLoaded: false setHistory((prev)=> { const copyPrev = {...prev} if((copyPrev?.customQDNHistoryPaths || []).at(-1) === (event?.data?.payload?.customQDNHistoryPaths || []).at(-1)) { - console.log('customQDNHistoryPaths.length', prev?.customQDNHistoryPaths.length) return { ...prev, currentIndex: prev.customQDNHistoryPaths.length - 1 === -1 ? 0 : prev.customQDNHistoryPaths.length - 1 } } const copyHistory = {...prev} - const paths = [...(copyHistory?.customQDNHistoryPaths || []), ...(event?.data?.payload?.customQDNHistoryPaths || [])] - console.log('paths', paths) + const paths = [...(copyHistory?.customQDNHistoryPaths.slice(0, copyHistory.currentIndex + 1) || []), ...(event?.data?.payload?.customQDNHistoryPaths || [])] return { ...prev, customQDNHistoryPaths: paths, @@ -445,7 +443,7 @@ isDOMContentLoaded: false setHistory(event?.data?.payload) } - } else if(event?.data?.action === 'SET_TAB'){ + } else if(event?.data?.action === 'SET_TAB'){ executeEvent("addTab", { data: event?.data?.payload })