mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 20:40:15 +02:00
fix unauthenticated flow
This commit is contained in:
@@ -238,6 +238,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
context: 'name',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
required
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<TextInput
|
||||
@@ -246,6 +247,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
context: 'url',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
required
|
||||
{...form.getInputProps('url')}
|
||||
/>
|
||||
</Group>
|
||||
@@ -254,6 +256,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
context: 'username',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
required
|
||||
{...form.getInputProps('username')}
|
||||
/>
|
||||
<PasswordInput
|
||||
@@ -298,7 +301,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<Group justify="flex-end">
|
||||
<Group grow>
|
||||
{onCancel && (
|
||||
<ModalButton onClick={onCancel}>{t('common.cancel')}</ModalButton>
|
||||
)}
|
||||
|
||||
@@ -58,6 +58,11 @@ export const useServerAuthenticated = () => {
|
||||
}, 300);
|
||||
|
||||
useEffect(() => {
|
||||
if (!server) {
|
||||
setReady(AuthState.INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
if (priorServerId.current !== server?.id) {
|
||||
const serverWithAuth = getServerById(server!.id);
|
||||
priorServerId.current = server?.id || '';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NuqsAdapter } from '@offlegacy/nuqs-hash-router';
|
||||
import isElectron from 'is-electron';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import { Navigate, Outlet } from 'react-router';
|
||||
|
||||
import { useServerAuthenticated } from '/@/renderer/hooks/use-server-authenticated';
|
||||
@@ -8,16 +7,10 @@ import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
import { Center } from '/@/shared/components/center/center';
|
||||
import { Spinner } from '/@/shared/components/spinner/spinner';
|
||||
import { toast } from '/@/shared/components/toast/toast';
|
||||
import { AuthState } from '/@/shared/types/types';
|
||||
|
||||
const ipc = isElectron() ? window.api.ipc : null;
|
||||
const utils = isElectron() ? window.api.utils : null;
|
||||
const mpvPlayerListener = isElectron() ? window.api.mpvPlayerListener : null;
|
||||
|
||||
export const AppOutlet = () => {
|
||||
const currentServer = useCurrentServer();
|
||||
// const setFallback = useSetPlayerFallback();
|
||||
const authState = useServerAuthenticated();
|
||||
|
||||
const isActionsRequired = useMemo(() => {
|
||||
@@ -29,21 +22,6 @@ export const AppOutlet = () => {
|
||||
return isActionRequired;
|
||||
}, [currentServer]);
|
||||
|
||||
// useEffect(() => {
|
||||
// utils?.mainMessageListener((_event, data) => {
|
||||
// toast.show(data);
|
||||
// });
|
||||
|
||||
// mpvPlayerListener?.rendererPlayerFallback((_event, data) => {
|
||||
// setFallback(data);
|
||||
// });
|
||||
|
||||
// return () => {
|
||||
// ipc?.removeAllListeners('toast-from-main');
|
||||
// ipc?.removeAllListeners('renderer-player-fallback');
|
||||
// };
|
||||
// }, [setFallback]);
|
||||
|
||||
if (authState === AuthState.LOADING) {
|
||||
return (
|
||||
<Center h="100vh" w="100%">
|
||||
|
||||
@@ -116,6 +116,10 @@ export const useCurrentServerId = () => useAuthStore((state) => state.currentSer
|
||||
|
||||
export const useCurrentServer = () =>
|
||||
useAuthStore((state) => {
|
||||
if (!state.currentServer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
features: state.currentServer?.features,
|
||||
id: state.currentServer?.id,
|
||||
|
||||
Reference in New Issue
Block a user