mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
Fix action required for mpv
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import isElectron from 'is-electron';
|
||||
import { FileInput, Text, Button } from '@/renderer/components';
|
||||
import { settings } from '@/renderer/features/settings';
|
||||
import { localSettings } from '@/renderer/features/settings';
|
||||
|
||||
export const MpvRequired = () => {
|
||||
const [mpvPath, setMpvPath] = useState('');
|
||||
const handleSetMpvPath = (e: File) => {
|
||||
settings.set('mpv_path', e.path);
|
||||
localSettings.set('mpv_path', e.path);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const getMpvPath = async () => {
|
||||
if (!isElectron()) return setMpvPath('');
|
||||
const mpvPath = await settings.get('mpv_path');
|
||||
const mpvPath = await localSettings.get('mpv_path');
|
||||
return setMpvPath(mpvPath);
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ export const MpvRequired = () => {
|
||||
below.
|
||||
</Text>
|
||||
<FileInput placeholder={mpvPath} onChange={handleSetMpvPath} />
|
||||
<Button onClick={() => settings.restart()}>Restart</Button>
|
||||
<Button onClick={() => localSettings.restart()}>Restart</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ActionRequiredContainer } from '@/renderer/features/action-required/com
|
||||
import { MpvRequired } from '@/renderer/features/action-required/components/mpv-required';
|
||||
import { ServerCredentialRequired } from '@/renderer/features/action-required/components/server-credential-required';
|
||||
import { ServerRequired } from '@/renderer/features/action-required/components/server-required';
|
||||
import { settings } from '@/renderer/features/settings';
|
||||
import { localSettings } from '@/renderer/features/settings';
|
||||
import { AnimatedPage, useServerCredential } from '@/renderer/features/shared';
|
||||
import { AppRoute } from '@/renderer/router/routes';
|
||||
import { useAuthStore } from '@/renderer/store';
|
||||
@@ -23,7 +23,7 @@ export const ActionRequiredRoute = () => {
|
||||
useEffect(() => {
|
||||
const getMpvPath = async () => {
|
||||
if (!isElectron()) return setIsMpvRequired(false);
|
||||
const mpvPath = await settings.get('mpv_path');
|
||||
const mpvPath = await localSettings.get('mpv_path');
|
||||
return setIsMpvRequired(!mpvPath);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import isElectron from 'is-electron';
|
||||
import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
||||
import { settings } from '@/renderer/features/settings';
|
||||
import { localSettings } from '@/renderer/features/settings';
|
||||
import { useServerCredential } from '@/renderer/features/shared';
|
||||
import { AppRoute } from '@/renderer/router/routes';
|
||||
import { useAuthStore } from '@/renderer/store';
|
||||
@@ -24,7 +24,7 @@ export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
||||
useEffect(() => {
|
||||
const getMpvPath = async () => {
|
||||
if (!isElectron()) return setIsMpvRequired(false);
|
||||
const mpvPath = await settings.get('mpv_path');
|
||||
const mpvPath = await localSettings.get('mpv_path');
|
||||
return setIsMpvRequired(!mpvPath);
|
||||
};
|
||||
|
||||
@@ -34,10 +34,6 @@ export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
||||
const actions = [isServerRequired, isCredentialRequired, isMpvRequired];
|
||||
const actionRequired = actions.some((c) => c);
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
if (isAuthenticated && actionRequired) {
|
||||
return (
|
||||
<Navigate
|
||||
@@ -48,6 +44,10 @@ export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
logout();
|
||||
return <Navigate replace state={{ from: location }} to={redirectTo} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user