diff --git a/.env b/.env index 0b6d5c3c8..db206b8e0 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VITE_TELEGRAM_BOT_USERNAME=steve_test_bot +VITE_TELEGRAM_BOT_USERNAME=steve_test_robot diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 4e5edbab6..2c3a01ab8 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { openUrl } from '@tauri-apps/plugin-opener'; +import { openUrl } from '../utils/openUrl'; import { TELEGRAM_BOT_USERNAME } from '../utils/config'; import ConnectionIndicator from '../components/ConnectionIndicator'; @@ -24,11 +24,7 @@ const Home = () => { // Handle Telegram bot link const handleStartCooking = async () => { - try { - await openUrl(`https://t.me/${TELEGRAM_BOT_USERNAME}`); - } catch (error) { - console.error('Failed to open Telegram:', error); - } + await openUrl(`https://t.me/${TELEGRAM_BOT_USERNAME}`); }; const handleManageConnections = () => { diff --git a/src/pages/onboarding/steps/GetStartedStep.tsx b/src/pages/onboarding/steps/GetStartedStep.tsx index 0fe67063b..7763810e2 100644 --- a/src/pages/onboarding/steps/GetStartedStep.tsx +++ b/src/pages/onboarding/steps/GetStartedStep.tsx @@ -1,4 +1,4 @@ -import { openUrl } from '@tauri-apps/plugin-opener'; +import { openUrl } from '../../../utils/openUrl'; import { TELEGRAM_BOT_USERNAME } from '../../../utils/config'; import ConnectionIndicator from '../../../components/ConnectionIndicator'; @@ -8,15 +8,9 @@ interface GetStartedStepProps { const GetStartedStep = ({ onComplete }: GetStartedStepProps) => { const handleOpenTelegram = async () => { - try { - // Open Telegram and navigate to home immediately - await openUrl(`https://t.me/${TELEGRAM_BOT_USERNAME}`); - onComplete(); - } catch (error) { - console.error('Failed to open Telegram:', error); - // Still navigate to home even if opening Telegram fails - onComplete(); - } + // Open Telegram and navigate to home immediately + await openUrl(`https://t.me/${TELEGRAM_BOT_USERNAME}`); + onComplete(); }; return ( diff --git a/src/utils/openUrl.ts b/src/utils/openUrl.ts new file mode 100644 index 000000000..678791199 --- /dev/null +++ b/src/utils/openUrl.ts @@ -0,0 +1,21 @@ +import { openUrl as tauriOpenUrl } from '@tauri-apps/plugin-opener'; + +/** + * Opens a URL in the default browser or app. + * Works in both Tauri desktop app and regular browser environments. + */ +export const openUrl = async (url: string): Promise => { + // Check if we're running in Tauri desktop app + if ((window as any).__TAURI__) { + try { + await tauriOpenUrl(url); + return; + } catch (error) { + console.error('Failed to open URL with Tauri:', error); + // Fall through to browser fallback + } + } + + // Browser fallback + window.open(url, '_blank', 'noopener,noreferrer'); +};