From d336b92e46aa16821bdfd484926a43d56b945348 Mon Sep 17 00:00:00 2001 From: marcobaobao Date: Wed, 10 Apr 2024 12:52:17 +0200 Subject: [PATCH] code refactoring --- frontend/src/components/HomeActions.tsx | 23 +---------------------- server/rpc/service.go | 1 + 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/frontend/src/components/HomeActions.tsx b/frontend/src/components/HomeActions.tsx index 184c264..bdbb7e9 100644 --- a/frontend/src/components/HomeActions.tsx +++ b/frontend/src/components/HomeActions.tsx @@ -1,6 +1,6 @@ import { Suspense, useState } from 'react' import { useRecoilState } from 'recoil' -import { loadingAtom, optimisticDownloadsState } from '../atoms/ui' +import { loadingAtom } from '../atoms/ui' import { useToast } from '../hooks/toast' import DownloadDialog from './DownloadDialog' import HomeSpeedDial from './HomeSpeedDial' @@ -8,32 +8,12 @@ import TemplatesEditor from './TemplatesEditor' const HomeActions: React.FC = () => { const [, setIsLoading] = useRecoilState(loadingAtom) - const [optimistic, setOptimistic] = useRecoilState(optimisticDownloadsState) const [openDownload, setOpenDownload] = useState(false) const [openEditor, setOpenEditor] = useState(false) const { pushMessage } = useToast() - // it's stupid because it will be overriden on the next server tick - const handleOptimisticUpdate = (url: string) => setOptimistic([ - ...optimistic, { - id: url, - info: { - created_at: new Date().toISOString(), - thumbnail: '', - title: url, - url: url - }, - progress: { - eta: Number.MAX_SAFE_INTEGER, - percentage: '0%', - process_status: 0, - speed: 0 - } - } - ]) - return ( <> { }} // TODO: handle optimistic UI update onDownloadStart={(url) => { - handleOptimisticUpdate(url) pushMessage(`Requested ${url}`, 'info') setOpenDownload(false) setIsLoading(true) diff --git a/server/rpc/service.go b/server/rpc/service.go index f21e01a..fd59346 100644 --- a/server/rpc/service.go +++ b/server/rpc/service.go @@ -154,6 +154,7 @@ func (s *Service) UpdateExecutable(args NoArgs, updated *bool) error { err := updater.UpdateExecutable() if err != nil { *updated = true + s.logger.Info("Succesfully updated yt-dlp") return err } *updated = false