Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove not needed tabs from unrecognized #316

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/Panels/ShokoPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { ReactNode } from 'react';
import { Icon } from '@mdi/react';
import { mdiLoading } from '@mdi/js';

type Props = {
title: string;
Expand All @@ -9,7 +11,7 @@ type Props = {
titleTabs?: ReactNode;
};

const ShokoPanel = ({ className, title, options, children, titleTabs }: Props) => (
const ShokoPanel = ({ className, title, options, children, titleTabs, isFetching }: Props) => (
<div className={`${className ?? ''} flex flex-col overflow-hidden h-full`}>
<div className="flex justify-between items-center mr-2">
<span className="flex font-semibold text-base">{title}{titleTabs}</span>
Expand All @@ -22,8 +24,8 @@ const ShokoPanel = ({ className, title, options, children, titleTabs }: Props) =
</div>
</div>
<span className="bg-background-border my-4 h-0.5 flex-shrink-0" />
<div className="flex flex-col mr-2 font-open-sans">
{children}
<div className="flex grow flex-col mr-2 font-open-sans">
{isFetching ? <div className="flex grow justify-center items-center"><Icon path={mdiLoading} spin size={1} /></div> : children}
</div>
</div>
);
Expand Down
4 changes: 4 additions & 0 deletions src/core/sagas/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ApiDashboard from '../api/v3/dashboard';

import {
setFetched,
unsetFetched,
setSeriesSummary,
setStats,
setRecentEpisodes,
Expand Down Expand Up @@ -71,16 +72,19 @@ function* getDashboardContinueWatching() {
}

yield put(setContinueWatching(resultJson.data));
yield put(setFetched('continueWatching'));
}

function* getDashboardUpcomingAnime(action: PayloadAction<boolean>) {
yield put(unsetFetched('upcomingAnime'));
const resultJson = yield call(ApiDashboard.getDashboardAniDBCalendar, action.payload);
if (resultJson.error) {
toast.error(resultJson.message);
return;
}

yield put(setUpcomingAnime(resultJson.data));
yield put(setFetched('upcomingAnime'));
}

export default {
Expand Down
1 change: 0 additions & 1 deletion src/core/sagas/mainpage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function* eventMainPageLoad() {
yield call(SagaImportFolder.getImportFolders),
yield call(SagaDashboard.getDashboardRecentlyAddedEpisodes),
yield call(SagaDashboard.getDashboardRecentlyAddedSeries),
yield call(SagaFile.getRecentFiles),
yield call(SagaFile.getUnrecognizedFiles),
yield call(SagaDashboard.getDashboardContinueWatching),
yield call(SagaDashboard.getDashboardUpcomingAnime, { type: Events.DASHBOARD_UPCOMING_ANIME, payload: false }),
Expand Down
3 changes: 2 additions & 1 deletion src/pages/dashboard/panels/ContinueWatching.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DashboardEpisodeDetailsType } from '../../../core/types/api/dashboard';

const ContinueWatching = () => {
const items = useSelector((state: RootState) => state.mainpage.continueWatching);
const hasFetched = useSelector((state: RootState) => state.mainpage.fetched.continueWatching);

const renderDetails = (item: DashboardEpisodeDetailsType ) => {

Expand All @@ -17,7 +18,7 @@ const ContinueWatching = () => {
};

return (
<ShokoPanel title="Continue Watching">
<ShokoPanel title="Continue Watching" isFetching={!hasFetched}>
<div className="flex flex-nowrap overflow-x-auto shoko-scrollbar h-90">{items.map(item => renderDetails(item))}</div>
</ShokoPanel>
);
Expand Down
34 changes: 3 additions & 31 deletions src/pages/dashboard/panels/ImportBreakdown.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,18 @@
import React, { useState } from 'react';
import React from 'react';
import { useSelector } from 'react-redux';
import cx from 'classnames';

import { RootState } from '../../../core/store';
import ShokoPanel from '../../../components/Panels/ShokoPanel';
import Button from '../../../components/Input/Button';
import ImportedTab from './ImportBreakdownTabs/ImportedTab';
import UnrecognizedTab from './ImportBreakdownTabs/UnrecognizedTab';

function ImportBreakdown() {
const hasFetchedRecents = useSelector((state: RootState) => state.mainpage.fetched.recentFiles);
const hasFetchedUnrecognized = useSelector(
(state: RootState) => state.mainpage.fetched.unrecognizedFiles,
);

const [activeTab, setActiveTab] = useState('unrecognized');

const renderOptions = () => (
<div className="font-open-sans font-semibold">
<Button onClick={() => setActiveTab('imported')} className={cx(['mr-2 font-open-sans font-semibold', activeTab === 'imported' && 'color-highlight-1'])}>
Imported
</Button>
<Button onClick={() => setActiveTab('unrecognized')} className={cx(['mr-2 font-open-sans font-semibold', activeTab === 'unrecognized' && 'color-highlight-1'])}>
Unrecognized
</Button>
</div>
);

const renderContent = () => {
switch (activeTab) {
case 'imported':
return <ImportedTab />;
case 'unrecognized':
return <UnrecognizedTab />;
default:
return <UnrecognizedTab />;
}
};

return (
<ShokoPanel title="Unrecognized" options={renderOptions()} isFetching={!(activeTab === 'unrecognized' ? hasFetchedUnrecognized : hasFetchedRecents)}>
{renderContent()}
<ShokoPanel title="Unrecognized" isFetching={!hasFetchedUnrecognized}>
<UnrecognizedTab />
</ShokoPanel>
);
}
Expand Down
160 changes: 0 additions & 160 deletions src/pages/dashboard/panels/ImportBreakdownTabs/ImportedTab.tsx

This file was deleted.

4 changes: 1 addition & 3 deletions src/pages/dashboard/panels/ImportFolders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ function ImportFolders() {
};

const renderOptions = () => (
<div>
<Button className="color-highlight-1 mx-2" onClick={() => setImportFolderModalStatus(true)} tooltip="Add Folder">
<div className="color-highlight-1 mx-2 cursor-pointer" onClick={() => setImportFolderModalStatus(true)} title="Add Folder">
<Icon path={mdiFolderPlusOutline} size={1} horizontal vertical rotate={180}/>
</Button>
</div>
);

Expand Down
8 changes: 4 additions & 4 deletions src/pages/dashboard/panels/QueueProcessor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ function QueueProcessor() {
return (
<React.Fragment>
{paused ? (
<Button className="color-highlight-1 mx-2" onClick={() => handleOperation!('Start')} tooltip="Resume All">
<div className="color-highlight-1 mx-2 cursor-pointer" onClick={() => handleOperation!('Start')} title="Resume All">
<Icon path={mdiCloseCircleOutline} size={1} horizontal vertical rotate={180} />
</Button>
</div>
) : (
<Button className="color-highlight-1 mx-2" onClick={() => handleOperation!('Pause')} tooltip="Pause All">
<div className="color-highlight-1 mx-2 cursor-pointer" onClick={() => handleOperation!('Pause')} title="Pause All">
<Icon path={mdiPauseCircleOutline} size={1} horizontal vertical rotate={180} />
</Button>
</div>
)}
</React.Fragment>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/dashboard/panels/RecentlyImported.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { SeriesType } from '../../../core/types/api/series';

const Title = ({ showSeries, setShowSeries }) => (<div>
<span className="px-2">&gt;</span>
<span className={cx({ 'font-semibold': showSeries === false, 'text-highlight-1': showSeries === false })} onClick={() => { setShowSeries(false);}}>Episodes</span>
<span className={cx({ 'cursor-pointer': true, 'font-semibold': showSeries === false, 'text-highlight-1': showSeries === false })} onClick={() => { setShowSeries(false);}}>Episodes</span>
<span className="mx-2">|</span>
<span className={cx({ 'font-semibold': showSeries, 'text-highlight-1': showSeries })} onClick={() => { setShowSeries(true);}}>Series</span>
<span className={cx({ 'cursor-pointer': true, 'font-semibold': showSeries, 'text-highlight-1': showSeries })} onClick={() => { setShowSeries(true);}}>Series</span>
</div>
);

Expand Down
7 changes: 4 additions & 3 deletions src/pages/dashboard/panels/UpcomingAnime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ const CalendarConfig: moment.CalendarSpec = {

const Title = ({ showAll, setShowAll }) => (<div>
<span className="px-2">&gt;</span>
<span className={cx({ 'font-semibold': showAll === false, 'text-highlight-1': showAll === false })} onClick={() => { setShowAll(false);}}>My Collection</span>
<span className={cx({ 'cursor-pointer': true, 'font-semibold': showAll === false, 'text-highlight-1': showAll === false })} onClick={() => { setShowAll(false);}}>My Collection</span>
<span className="mx-2">|</span>
<span className={cx({ 'font-semibold': showAll, 'text-highlight-1': showAll })} onClick={() => { setShowAll(true);}}>All</span>
<span className={cx({ 'cursor-pointer': true, 'font-semibold': showAll, 'text-highlight-1': showAll })} onClick={() => { setShowAll(true);}}>All</span>
</div>
);

const UpcomingAnime = () => {
const items = useSelector((state: RootState) => state.mainpage.upcomingAnime);
const hasFetched = useSelector((state: RootState) => state.mainpage.fetched.upcomingAnime);
const [showAll, setShowAll] = useState(false);

const dispatch = useDispatch();
Expand All @@ -49,7 +50,7 @@ const UpcomingAnime = () => {
};

return (
<ShokoPanel title="Upcoming Anime" titleTabs={<Title showAll={showAll} setShowAll={updatePanel} />}>
<ShokoPanel title="Upcoming Anime" isFetching={!hasFetched} titleTabs={<Title showAll={showAll} setShowAll={updatePanel} />}>
<div className="flex flex-nowrap overflow-x-auto shoko-scrollbar h-90 pb-5">{items.map(item => renderDetails(item))}</div>
</ShokoPanel>
);
Expand Down