mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
Add hook to fetch current server cred
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
import { useAuthStore } from '@/renderer/store';
|
||||||
|
import { ServerType } from '@/renderer/types';
|
||||||
|
|
||||||
|
export const useServerCredential = () => {
|
||||||
|
const serverId = useAuthStore((state) => state.currentServer?.id) || '';
|
||||||
|
const serverType = useAuthStore((state) => state.currentServer?.type);
|
||||||
|
const serverCredential = useAuthStore(
|
||||||
|
(state) => state.serverCredentials
|
||||||
|
).find((c) => c.serverId === serverId && c.enabled)?.token;
|
||||||
|
|
||||||
|
const isImageTokenRequired =
|
||||||
|
serverCredential &&
|
||||||
|
(serverType === ServerType.SUBSONIC || serverType === ServerType.NAVIDROME);
|
||||||
|
|
||||||
|
return {
|
||||||
|
isImageTokenRequired,
|
||||||
|
serverToken: serverCredential,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './components/animated-page';
|
export * from './components/animated-page';
|
||||||
export * from './hooks/use-permissions';
|
export * from './hooks/use-permissions';
|
||||||
|
export * from './hooks/use-server-credential';
|
||||||
|
|||||||
Reference in New Issue
Block a user