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

Remember Upcoming Anime Panel Selection. #1169

Merged
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
1 change: 1 addition & 0 deletions src/core/react-query/settings/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export const initialSettings: SettingsType = {
recentlyImportedEpisodesCount: 30,
recentlyImportedSeriesCount: 20,
recentlyImportedView: 'episodes',
upcomingAnimeView: 'collection',
},
},
FirstRun: false,
Expand Down
1 change: 1 addition & 0 deletions src/core/types/api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export type WebUISettingsType = {
recentlyImportedEpisodesCount: number;
recentlyImportedSeriesCount: number;
recentlyImportedView: 'episodes' | 'series';
upcomingAnimeView: 'collection' | 'all';
};
};

Expand Down
21 changes: 16 additions & 5 deletions src/pages/dashboard/panels/UpcomingAnime.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import { produce } from 'immer';
import { map } from 'lodash';

import MultiStateButton from '@/components/Input/MultiStateButton';
import ShokoPanel from '@/components/Panels/ShokoPanel';
import TransitionDiv from '@/components/TransitionDiv';
import { useDashboardCalendarQuery } from '@/core/react-query/dashboard/queries';
import { usePatchSettingsMutation } from '@/core/react-query/settings/mutations';
import { useSettingsQuery } from '@/core/react-query/settings/queries';
import useEventCallback from '@/hooks/useEventCallback';
import EpisodeDetails from '@/pages/dashboard/components/EpisodeDetails';

import type { RootState } from '@/core/store';

type TabType = 'collection_only' | 'all';
type TabType = 'collection' | 'all';
const tabStates: { label?: string, value: TabType }[] = [
{ label: 'My Collection', value: 'collection_only' },
{ label: 'My Collection', value: 'collection' },
{ label: 'All', value: 'all' },
];

const UpcomingAnime = () => {
const layoutEditMode = useSelector((state: RootState) => state.mainpage.layoutEditMode);

const [currentTab, setCurrentTab] = useState<TabType>(tabStates[0].value);
const handleTabChange = useEventCallback((newTab: TabType) => setCurrentTab(newTab));
const settings = useSettingsQuery().data;
const { hideR18Content, upcomingAnimeView } = useSettingsQuery().data.WebUI_Settings.dashboard;
const { mutate: patchSettings } = usePatchSettingsMutation();

const { hideR18Content } = useSettingsQuery().data.WebUI_Settings.dashboard;
const [currentTab, setCurrentTab] = useState<TabType>(upcomingAnimeView);

const calendarQuery = useDashboardCalendarQuery({ showAll: false, includeRestricted: !hideR18Content });
const calendarAllQuery = useDashboardCalendarQuery({ showAll: true, includeRestricted: !hideR18Content });

const handleTabChange = useEventCallback((newTab: TabType) => {
setCurrentTab(newTab);
const newSettings = produce(settings, (draftState) => {
draftState.WebUI_Settings.dashboard.upcomingAnimeView = newTab;
});
patchSettings({ newSettings });
});

return (
<ShokoPanel
title="Upcoming Anime"
Expand Down
Loading