Skip to content

Commit

Permalink
Run import automatically on finishing first run setup, update unsuppo…
Browse files Browse the repository at this point in the history
…rted page (#965)

* Run import automatically on finishing first run setup

* Remove `GA_OptOutPlzDont` from settings model

* Update unsupported page
  • Loading branch information
harshithmohan authored Aug 10, 2024
1 parent fdaf6d5 commit edc25a1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/core/react-query/settings/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ export const initialSettings: SettingsType = {
Delete: false,
Delete_Days: '0',
},
GA_OptOutPlzDont: false,
AutoGroupSeries: false,
AutoGroupSeriesUseScoreAlgorithm: false,
AutoGroupSeriesRelationExclusions: [],
Expand Down
1 change: 0 additions & 1 deletion src/core/types/api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ export type SettingsServerType = {
TraktTv: SettingsTraktType;
Plex: SettingsPlexType;
LogRotator: SettingsLogRotatorType;
GA_OptOutPlzDont: boolean;
AutoGroupSeries: boolean;
AutoGroupSeriesUseScoreAlgorithm: boolean;
AutoGroupSeriesRelationExclusions: string[];
Expand Down
15 changes: 12 additions & 3 deletions src/pages/firstrun/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useNavigate } from 'react-router-dom';
import cx from 'classnames';

import Button from '@/components/Input/Button';
import { useRunActionMutation } from '@/core/react-query/action/mutations';
import useEventCallback from '@/hooks/useEventCallback';

import type { TestStatusType } from '@/core/slices/firstrun';

Expand All @@ -19,11 +21,18 @@ type Props = {
function Footer(props: Props) {
const navigate = useNavigate();

const handleNext = () => {
const { mutate: runAction } = useRunActionMutation();

const handleNext = useEventCallback(() => {
const { nextPage, saveFunction } = props;
if (saveFunction) saveFunction();
if (nextPage) navigate(`../${nextPage}`);
};
});

const handleFinish = useEventCallback(() => {
runAction('RunImport');
navigate('/webui/dashboard', { replace: true, state: { firstRun: true } });
});

const {
finish,
Expand All @@ -50,7 +59,7 @@ function Footer(props: Props) {
{finish
? (
<Button
onClick={() => navigate('/webui/dashboard', { replace: true, state: { firstRun: true } })}
onClick={handleFinish}
buttonType="primary"
className="w-1/2 px-4 py-2"
disabled={nextDisabled}
Expand Down
17 changes: 14 additions & 3 deletions src/pages/login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ import { useLoginMutation } from '@/core/react-query/auth/mutations';
import { useRandomImageMetadataQuery } from '@/core/react-query/image/queries';
import { useServerStatusQuery, useVersionQuery } from '@/core/react-query/init/queries';
import { ImageTypeEnum } from '@/core/types/api/common';
import { dayjs } from '@/core/util';

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

// This is the release date because that's all we have
const mininumSupportedServerDate = dayjs('2024-08-04T17:46:27Z');

function LoginPage() {
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
Expand Down Expand Up @@ -111,9 +115,16 @@ function LoginPage() {
}, [versionQuery.data, versionQuery.isFetching]);

useEffect(() => {
if (
versionQuery?.data?.Server?.ReleaseDate === undefined && versionQuery?.data?.Server?.ReleaseChannel === 'Stable'
) {
if (!versionQuery.data) return;

const serverData = versionQuery.data.Server;

let isServerSupported = true;

if (!serverData.ReleaseDate && serverData.ReleaseChannel === 'Stable') isServerSupported = false;
if (dayjs(serverData.ReleaseDate).isBefore(mininumSupportedServerDate)) isServerSupported = false;

if (!isServerSupported) {
navigate('/webui/unsupported');
}
}, [navigate, versionQuery.data]);
Expand Down
22 changes: 20 additions & 2 deletions src/pages/unsupported/UnsupportedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { useDispatch } from 'react-redux';
import ShokoMascot from '@/../images/shoko_mascot.png';
import Button from '@/components/Input/Button';
import Events from '@/core/events';
import { useVersionQuery } from '@/core/react-query/init/queries';
import { useUpdateWebuiMutation } from '@/core/react-query/webui/mutations';
import useEventCallback from '@/hooks/useEventCallback';

const UnsupportedPage = () => {
const dispatch = useDispatch();
const { isPending: isUpdateWebuiPending, mutate: updateWebui } = useUpdateWebuiMutation();

const versionQuery = useVersionQuery();

const handleLogout = useEventCallback(() => {
dispatch({ type: Events.AUTH_LOGOUT });
});
Expand All @@ -32,8 +35,13 @@ const UnsupportedPage = () => {
Shoko Server you have installed.
</div>
<div>
Select the&nbsp;
<span className="font-semibold text-panel-text-important">Force Update to Stable Web UI</span>
If you are using the daily version of Shoko Server, you should update your server to the latest daily. If
you do not want to update your server, find the daily Web UI version which works and manually downgrade to
it.
</div>
<div>
If you are running the stable version of Shoko Server, select the&nbsp;
<span className="font-semibold text-panel-text-important">Force Update to Stable Web UI&nbsp;</span>
button to have Shoko download the latest stable version of the Web UI which will work with your version of
Shoko Server.
</div>
Expand All @@ -49,6 +57,16 @@ const UnsupportedPage = () => {
</a>
&nbsp;server and provide the above error.
</div>
{versionQuery.data && (
<div>
Server Version:&nbsp;
{versionQuery.data.Server.Version}
{versionQuery.data.Server.Commit && `-${versionQuery.data.Server.Commit?.slice(0, 7)}`}
<br />
Web UI Version:&nbsp;
{versionQuery.data.WebUI?.Version}
</div>
)}
</div>
<div className="flex flex-col gap-y-2 md:flex-row md:gap-x-4">
<Button
Expand Down

0 comments on commit edc25a1

Please sign in to comment.