diff --git a/web/app/components/app/app-publisher/index.tsx b/web/app/components/app/app-publisher/index.tsx index 39eb53da8b..801345798b 100644 --- a/web/app/components/app/app-publisher/index.tsx +++ b/web/app/components/app/app-publisher/index.tsx @@ -223,8 +223,8 @@ const AppPublisher = ({ openAsync( async () => { - const { installed_apps }: any = await fetchInstalledAppList(appDetail.id) || {} - if (installed_apps?.length > 0) + const { installed_apps }: { installed_apps?: { id: string }[] } = await fetchInstalledAppList(appDetail.id) || {} + if (installed_apps && installed_apps.length > 0) return `${basePath}/explore/installed/${installed_apps[0].id}` throw new Error('No app found in Explore') }, diff --git a/web/app/components/apps/app-card.tsx b/web/app/components/apps/app-card.tsx index b9a4c656d3..407df23913 100644 --- a/web/app/components/apps/app-card.tsx +++ b/web/app/components/apps/app-card.tsx @@ -252,8 +252,8 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { openAsync( async () => { - const { installed_apps }: any = await fetchInstalledAppList(app.id) || {} - if (installed_apps?.length > 0) + const { installed_apps }: { installed_apps?: { id: string }[] } = await fetchInstalledAppList(app.id) || {} + if (installed_apps && installed_apps.length > 0) return `${basePath}/explore/installed/${installed_apps[0].id}` throw new Error('No app found in Explore') }, diff --git a/web/hooks/use-async-window-open.ts b/web/hooks/use-async-window-open.ts index dcc44e7846..582ab28be4 100644 --- a/web/hooks/use-async-window-open.ts +++ b/web/hooks/use-async-window-open.ts @@ -24,10 +24,20 @@ export const useAsyncWindowOpen = () => { const newWindow = window.open('', '_blank', windowFeatures) + if (!newWindow) { + const error = new Error('Popup blocked by browser') + onError?.(error) + Toast.notify({ + type: 'error', + message: 'Popup blocked. Please allow popups for this site.', + }) + return + } + try { const url = await fetchUrl() - if (url && newWindow) { + if (url) { newWindow.location.href = url onSuccess?.(url) @@ -39,8 +49,8 @@ export const useAsyncWindowOpen = () => { } } else { - newWindow?.close() - const error = new Error('Invalid URL or window was closed') + newWindow.close() + const error = new Error('Invalid URL received') onError?.(error) Toast.notify({ type: 'error', @@ -49,7 +59,7 @@ export const useAsyncWindowOpen = () => { } } catch (error) { - newWindow?.close() + newWindow.close() onError?.(error) Toast.notify({ type: 'error',