From 5f3728a8fde68e8afd4faeb0c147d5e14adb82f7 Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Sat, 17 Jan 2026 22:06:06 +0530 Subject: [PATCH] fix: downloading appimage update on native deb/rpm installation --- src/components/sidebar.tsx | 424 ++++++++++++++++++++----------------- 1 file changed, 224 insertions(+), 200 deletions(-) diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx index c8f0de8..9105dd8 100644 --- a/src/components/sidebar.tsx +++ b/src/components/sidebar.tsx @@ -14,214 +14,238 @@ import { Button } from "@/components/ui/button"; import { AlertDialog, AlertDialogContent, AlertDialogDescription, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog"; import { Progress } from "@/components/ui/progress"; import useAppUpdater from "@/helpers/use-app-updater"; +import { platform } from "@tauri-apps/plugin-os"; +import * as fs from "@tauri-apps/plugin-fs"; export function AppSidebar() { - const downloadStates = useDownloadStatesStore(state => state.downloadStates); - const ongoingDownloads = downloadStates.filter(state => - ['starting', 'downloading', 'queued'].includes(state.download_status) - ); - const appVersion = useSettingsPageStatesStore(state => state.appVersion); - const isFetchingAppVersion = useSettingsPageStatesStore(state => state.isFetchingAppVersion); - const appUpdate = useSettingsPageStatesStore(state => state.appUpdate); - const isUpdatingApp = useSettingsPageStatesStore(state => state.isUpdatingApp); - const appUpdateDownloadProgress = useSettingsPageStatesStore(state => state.appUpdateDownloadProgress); - const location = useLocation(); - const { open } = useSidebar(); - const { downloadAndInstallAppUpdate } = useAppUpdater(); - const [showBadge, setShowBadge] = useState(false); - const [showUpdateCard, setShowUpdateCard] = useState(false); + const downloadStates = useDownloadStatesStore(state => state.downloadStates); + const ongoingDownloads = downloadStates.filter(state => + ['starting', 'downloading', 'queued'].includes(state.download_status) + ); + const appVersion = useSettingsPageStatesStore(state => state.appVersion); + const isFetchingAppVersion = useSettingsPageStatesStore(state => state.isFetchingAppVersion); + const appUpdate = useSettingsPageStatesStore(state => state.appUpdate); + const isUpdatingApp = useSettingsPageStatesStore(state => state.isUpdatingApp); + const appUpdateDownloadProgress = useSettingsPageStatesStore(state => state.appUpdateDownloadProgress); + const currentPlatform = platform(); + const location = useLocation(); + const { open } = useSidebar(); + const { downloadAndInstallAppUpdate } = useAppUpdater(); + const [showBadge, setShowBadge] = useState(false); + const [showUpdateCard, setShowUpdateCard] = useState(false); + const [isNativeLinuxApp, setIsNativeLinuxApp] = useState(false); - const topItems: Array = [ - { - title: "Downloader", - url: "/", - icon: Download, - }, - { - title: "Library", - url: "/library", - icon: SquarePlay, - } - ]; + const topItems: Array = [ + { + title: "Downloader", + url: "/", + icon: Download, + }, + { + title: "Library", + url: "/library", + icon: SquarePlay, + } + ]; - const bottomItems: Array = [ - { - title: "Settings", - url: "/settings", - icon: Settings, - } - ]; + const bottomItems: Array = [ + { + title: "Settings", + url: "/settings", + icon: Settings, + } + ]; - useEffect(() => { - let timeout: NodeJS.Timeout; - if (open) { - timeout = setTimeout(() => { - setShowBadge(true); - setShowUpdateCard(true); - }, 300); - } else { - setShowBadge(false); - setShowUpdateCard(false); - } + useEffect(() => { + let timeout: NodeJS.Timeout; + if (open) { + timeout = setTimeout(() => { + setShowBadge(true); + setShowUpdateCard(true); + }, 300); + } else { + setShowBadge(false); + setShowUpdateCard(false); + } - return () => { - clearTimeout(timeout); - }; - }, [open]); + return () => { + clearTimeout(timeout); + }; + }, [open]); - return ( - - - - - - -
- -
-
- Neo Downloader Plus - {isFetchingAppVersion ? 'Loading...' : `v${appVersion}`} -
-
-
-
-
-
- {/* */} - - - {/* Tools */} - - - {topItems.map((item) => ( - - {!open ? ( - - - - - - {item.title} - {item.title === "Library" && ongoingDownloads.length > 0 && showBadge && ( - {ongoingDownloads.length} - )} - + useEffect(() => { + (async () => { + if (currentPlatform === 'linux') { + const neoDlpExists = await fs.exists('/usr/bin/neodlp'); + setIsNativeLinuxApp(neoDlpExists); + } + })(); + }, [currentPlatform]); + + return ( + + + + + + +
+ +
+
+ Neo Downloader Plus + {isFetchingAppVersion ? 'Loading...' : `v${appVersion}`} +
+
-
- -

{item.title}

-
+
+
+ + {/* */} + + + {/* Tools */} + + + {topItems.map((item) => ( + + {!open ? ( + + + + + + {item.title} + {item.title === "Library" && ongoingDownloads.length > 0 && showBadge && ( + {ongoingDownloads.length} + )} + + + + +

{item.title}

+
+
+ ) : ( + + + + {item.title} + {item.title === "Library" && ongoingDownloads.length > 0 && showBadge && ( + + {ongoingDownloads.length} + + )} + + + )} +
+ ))} +
+
+
+
+ + {appUpdate && !open && ( + + + + + +

Update Available

(Expand sidebar to view update)

+
- ) : ( - - - - {item.title} - {item.title === "Library" && ongoingDownloads.length > 0 && showBadge && ( - - {ongoingDownloads.length} - + )} + {appUpdate && open && showUpdateCard && ( + + + Update Available (v{appUpdate?.version || '0.0.0'}) + + A newer version of {config.appName} is available. Please update to the latest version for the best experience. + + ✨ Read Changelog + + + {isNativeLinuxApp ? ( + + ) : ( + + + + + + + + Updating {config.appName} + Updating {config.appName} to v{appUpdate?.version || '0.0.0'}, Please be patience! Do not quit the app untill the update finishes. The app will auto re-launch to complete the update, Please allow all system prompts from {config.appName} if asked. + + Downloading update... {appUpdateDownloadProgress}% + + + )} - - - )} - - ))} - -
-
-
- - {appUpdate && !open && ( - - - - - -

Update Available

(Expand sidebar to view update)

-
-
- )} - {appUpdate && open && showUpdateCard && ( - - - Update Available (v{appUpdate?.version || '0.0.0'}) - - A newer version of {config.appName} is available. Please update to the latest version for the best experience. - - ✨ Read Changelog - - - - - - - - - - Updating {config.appName} - Updating {config.appName} to v{appUpdate?.version || '0.0.0'}, Please be patience! Do not quit the app untill the update finishes. The app will auto re-launch to complete the update, Please allow all system prompts from {config.appName} if asked. - - Downloading update... {appUpdateDownloadProgress}% - - - - - - )} - - {bottomItems.map((item) => ( - - {!open ? ( - - - - - - {item.title} - - - - -

{item.title}

-
-
- ) : ( - - - - {item.title} - - - )} -
- ))} -
-
-
- ) + + + )} + + {bottomItems.map((item) => ( + + {!open ? ( + + + + + + {item.title} + + + + +

{item.title}

+
+
+ ) : ( + + + + {item.title} + + + )} +
+ ))} +
+ + + ); }