Merge branch 'master' into use-auto-dark-palette-and-About

This commit is contained in:
nikk
2021-06-17 20:39:16 +03:00
committed by GitHub
12 changed files with 136 additions and 56 deletions

View File

@@ -10,24 +10,26 @@ import SettingsDialog from 'components/Settings'
import RemoveAll from 'components/RemoveAll'
import AboutDialog from 'components/About'
import CloseServer from 'components/CloseServer'
import { memo } from 'react'
import { AppSidebarStyle } from './style'
export default function Sidebar({ isDrawerOpen, setIsDonationDialogOpen }) {
const Sidebar = ({ isDrawerOpen, setIsDonationDialogOpen, isOffline, isLoading }) => {
const { t } = useTranslation()
return (
<AppSidebarStyle isDrawerOpen={isDrawerOpen}>
<List>
<AddDialogButton />
<RemoveAll />
<AddDialogButton isOffline={isOffline} isLoading={isLoading} />
<RemoveAll isOffline={isOffline} isLoading={isLoading} />
</List>
<Divider />
<List>
<SettingsDialog />
<CloseServer />
<CloseServer isOffline={isOffline} isLoading={isLoading} />
</List>
<Divider />
@@ -45,3 +47,5 @@ export default function Sidebar({ isDrawerOpen, setIsDonationDialogOpen }) {
</AppSidebarStyle>
)
}
export default memo(Sidebar)

View File

@@ -13,6 +13,8 @@ import DonateSnackbar from 'components/Donate'
import DonateDialog from 'components/Donate/DonateDialog'
import useChangeLanguage from 'utils/useChangeLanguage'
import { ThemeProvider } from '@material-ui/core/styles'
import { useQuery } from 'react-query'
import { getTorrents } from 'utils/Utils'
import { AppWrapper, AppHeader, LanguageSwitch } from './style'
import Sidebar from './Sidebar'
@@ -56,6 +58,13 @@ export default function App() {
[prefersDarkMode],
)
const [currentLang, changeLang] = useChangeLanguage()
const [isOffline, setIsOffline] = useState(false)
const { data: torrents, isLoading } = useQuery('torrents', getTorrents, {
retry: 1,
refetchInterval: 1000,
onError: () => setIsOffline(true),
onSuccess: () => setIsOffline(false),
})
useEffect(() => {
axios.get(echoHost()).then(({ data }) => setTorrServerVersion(data))