import { useState, useEffect } from "react"; import { openUrl } from "@tauri-apps/plugin-opener"; import { Sidebar } from "./components/sidebar/Sidebar"; import { Feed } from "./components/feed/Feed"; import { SearchView } from "./components/search/SearchView"; import { RelaysView } from "./components/shared/RelaysView"; import { SettingsView } from "./components/shared/SettingsView"; import { ProfileView } from "./components/profile/ProfileView"; import { ThreadView } from "./components/thread/ThreadView"; import { ArticleEditor } from "./components/article/ArticleEditor"; import { ArticleView } from "./components/article/ArticleView"; import { ArticleFeed } from "./components/article/ArticleFeed"; import { MediaFeed } from "./components/media/MediaFeed"; import { OnboardingFlow } from "./components/onboarding/OnboardingFlow"; import { AboutView } from "./components/shared/AboutView"; import { ZapHistoryView } from "./components/zap/ZapHistoryView"; import { DMView } from "./components/dm/DMView"; import { NotificationsView } from "./components/notifications/NotificationsView"; import { BookmarkView } from "./components/bookmark/BookmarkView"; import { HashtagFeed } from "./components/feed/HashtagFeed"; import { HelpModal } from "./components/shared/HelpModal"; import { useUIStore } from "./stores/ui"; import { useUpdater } from "./hooks/useUpdater"; import { useKeyboardShortcuts } from "./hooks/useKeyboardShortcuts"; function UpdateBanner() { const { available, version, installing, error, install, dismiss } = useUpdater(); if (!available) return null; return (
Wrystr {version} is available.{" "} {error && {error}}
); } function App() { const currentView = useUIStore((s) => s.currentView); const showHelp = useUIStore((s) => s.showHelp); const toggleHelp = useUIStore((s) => s.toggleHelp); const [onboardingDone, setOnboardingDone] = useState( () => !!localStorage.getItem("wrystr_pubkey") ); useKeyboardShortcuts(); // Intercept external link clicks and open in system browser via Tauri opener useEffect(() => { const handler = (e: MouseEvent) => { const anchor = (e.target as HTMLElement).closest("a[href]") as HTMLAnchorElement | null; if (!anchor) return; const href = anchor.getAttribute("href"); if (!href) return; // Only intercept external http(s) links if (href.startsWith("http://") || href.startsWith("https://")) { e.preventDefault(); e.stopPropagation(); openUrl(href).catch(() => {}); } }; document.addEventListener("click", handler, true); return () => document.removeEventListener("click", handler, true); }, []); if (!onboardingDone) { return setOnboardingDone(true)} />; } return (
{currentView === "search" && } {currentView === "relays" && } {currentView === "settings" && } {currentView === "profile" && } {currentView === "thread" && } {currentView === "articles" && } {currentView === "media" && } {currentView === "article-editor" && } {currentView === "article" && } {currentView === "about" && } {currentView === "zaps" && } {currentView === "dm" && } {currentView === "notifications" && } {currentView === "bookmarks" && } {currentView === "hashtag" && }
{showHelp && }
); } export default App;