add prettier for auto formatting (#231)
* [Prettier] Add "prettier" Makes the formatting of the code consistent. By using the eslint-plugin-prettier formatting issues will be highlighted as a lint error. These errors will be auto fixed by running "lint --fix" (which can be done automatically on file save) * [Prettier] Add "prettier" - Fix formatting
This commit is contained in:
@@ -6,9 +6,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import { Warning } from '@mui/icons-material';
|
||||
import {
|
||||
CircularProgress, IconButton, Stack, Tooltip,
|
||||
} from '@mui/material';
|
||||
import { CircularProgress, IconButton, Stack, Tooltip } from '@mui/material';
|
||||
import { Box } from '@mui/system';
|
||||
import NavbarContext, { useSetDefaultBackTo } from 'components/context/NavbarContext';
|
||||
import ChapterList from 'components/manga/ChapterList';
|
||||
@@ -18,9 +16,7 @@ import MangaToolbarMenu from 'components/manga/MangaToolbarMenu';
|
||||
import { NavbarToolbar } from 'components/navbar/DefaultNavBar';
|
||||
import EmptyView from 'components/util/EmptyView';
|
||||
import LoadingPlaceholder from 'components/util/LoadingPlaceholder';
|
||||
import React, {
|
||||
useContext, useEffect, useRef,
|
||||
} from 'react';
|
||||
import React, { useContext, useEffect, useRef } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useQuery } from 'util/client';
|
||||
|
||||
@@ -32,12 +28,20 @@ const Manga: React.FC = () => {
|
||||
const autofetchedRef = useRef(false);
|
||||
|
||||
const {
|
||||
data: manga, error, loading, isValidating, mutate,
|
||||
data: manga,
|
||||
error,
|
||||
loading,
|
||||
isValidating,
|
||||
mutate,
|
||||
} = useQuery<IManga>(`/api/v1/manga/${id}/?onlineFetch=false`);
|
||||
|
||||
const [refresh, { loading: refreshing }] = useRefreshManga(id);
|
||||
|
||||
useSetDefaultBackTo(manga?.inLibrary === false && manga.sourceId != null ? `/sources/${manga.sourceId}/popular` : '/library');
|
||||
useSetDefaultBackTo(
|
||||
manga?.inLibrary === false && manga.sourceId != null
|
||||
? `/sources/${manga.sourceId}/popular`
|
||||
: '/library',
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// Automatically fetch manga from source if data is older then 24 hours
|
||||
@@ -45,9 +49,9 @@ const Manga: React.FC = () => {
|
||||
// not update age for some reason (ie. error on source side)
|
||||
if (manga == null) return;
|
||||
if (
|
||||
manga.inLibrary
|
||||
&& (manga.age > AUTOFETCH_AGE || manga.chaptersAge > AUTOFETCH_AGE)
|
||||
&& autofetchedRef.current === false
|
||||
manga.inLibrary &&
|
||||
(manga.age > AUTOFETCH_AGE || manga.chaptersAge > AUTOFETCH_AGE) &&
|
||||
autofetchedRef.current === false
|
||||
) {
|
||||
autofetchedRef.current = true;
|
||||
refresh();
|
||||
@@ -59,29 +63,28 @@ const Manga: React.FC = () => {
|
||||
}, [manga?.title]);
|
||||
|
||||
if (error && !manga) {
|
||||
return (
|
||||
<EmptyView message="Could not load manga" messageExtra={error.message ?? error} />
|
||||
);
|
||||
return <EmptyView message="Could not load manga" messageExtra={error.message ?? error} />;
|
||||
}
|
||||
return (
|
||||
<Box sx={{ display: { md: 'flex' }, overflow: 'hidden' }}>
|
||||
<NavbarToolbar>
|
||||
<Stack direction="row" alignItems="center">
|
||||
{error && !isValidating && !refreshing && (
|
||||
<Tooltip title={(
|
||||
<>
|
||||
Could not fetch manga data
|
||||
<br />
|
||||
{error.message ?? error}
|
||||
</>
|
||||
)}
|
||||
<Tooltip
|
||||
title={
|
||||
<>
|
||||
Could not fetch manga data
|
||||
<br />
|
||||
{error.message ?? error}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<IconButton onClick={() => mutate()}>
|
||||
<Warning color="error" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
)}
|
||||
{(manga && (refreshing || isValidating)) && (
|
||||
{manga && (refreshing || isValidating) && (
|
||||
<IconButton disabled>
|
||||
<CircularProgress size={16} />
|
||||
</IconButton>
|
||||
|
||||
Reference in New Issue
Block a user