chore(Auth): reorder exports in Auth component

fix(PluginAuthForm): handle case when pluginKey is null or undefined
fix(PluginStoreDialog): handle case when getAvailablePluginFromKey is null or undefined
fix(AuthContext): make authConfig optional in AuthContextProvider
feat(hooks): add useServerStream hook
fix(conversation): setSubmission to null instead of empty object
fix(preset): specify type for presets atom
fix(search): specify type for isSearchEnabled atom
fix(submission): specify type for submission atom
This commit is contained in:
Danny Avila 2023-08-18 12:02:39 -04:00 committed by Danny Avila
parent c40b95f424
commit d612cfcb45
9 changed files with 13 additions and 12 deletions

View file

@ -1,4 +1,5 @@
export { default as Login } from './Login'; export { default as Login } from './Login';
export { default as Registration } from './Registration'; export { default as Registration } from './Registration';
export { default as RequestPasswordReset } from './RequestPasswordReset';
export { default as ResetPassword } from './ResetPassword'; export { default as ResetPassword } from './ResetPassword';
export { default as ApiErrorWatcher } from './ApiErrorWatcher';
export { default as RequestPasswordReset } from './RequestPasswordReset';

View file

@ -23,7 +23,7 @@ function PluginAuthForm({ plugin, onSubmit }: TPluginAuthFormProps) {
className="col-span-1 flex w-full flex-col items-start justify-start gap-2" className="col-span-1 flex w-full flex-col items-start justify-start gap-2"
method="POST" method="POST"
onSubmit={handleSubmit((auth) => onSubmit={handleSubmit((auth) =>
onSubmit({ pluginKey: plugin?.pluginKey, action: 'install', auth }), onSubmit({ pluginKey: plugin?.pluginKey ?? '', action: 'install', auth }),
)} )}
> >
{plugin?.authConfig?.map((config: TPluginAuthConfig, i: number) => ( {plugin?.authConfig?.map((config: TPluginAuthConfig, i: number) => (

View file

@ -84,10 +84,9 @@ function PluginStoreDialog({ isOpen, setIsOpen }: TPluginStoreDialogProps) {
const getAvailablePluginFromKey = availablePlugins?.find((p) => p.pluginKey === pluginKey); const getAvailablePluginFromKey = availablePlugins?.find((p) => p.pluginKey === pluginKey);
setSelectedPlugin(getAvailablePluginFromKey); setSelectedPlugin(getAvailablePluginFromKey);
if ( const { authConfig, authenticated } = getAvailablePluginFromKey ?? {};
getAvailablePluginFromKey?.authConfig.length > 0 &&
!getAvailablePluginFromKey?.authenticated if (authConfig && authConfig.length > 0 && !authenticated) {
) {
setShowPluginAuthForm(true); setShowPluginAuthForm(true);
} else { } else {
handleInstall({ pluginKey, action: 'install', auth: null }); handleInstall({ pluginKey, action: 'install', auth: null });

View file

@ -46,7 +46,7 @@ const AuthContextProvider = ({
authConfig, authConfig,
children, children,
}: { }: {
authConfig: TAuthConfig; authConfig?: TAuthConfig;
children: ReactNode; children: ReactNode;
}) => { }) => {
const [user, setUser] = useState<TUser | undefined>(undefined); const [user, setUser] = useState<TUser | undefined>(undefined);

View file

@ -7,4 +7,5 @@ export { default as useLocalize } from './useLocalize';
export { default as useMediaQuery } from './useMediaQuery'; export { default as useMediaQuery } from './useMediaQuery';
export { default as useSetOptions } from './useSetOptions'; export { default as useSetOptions } from './useSetOptions';
export { default as useGenerations } from './useGenerations'; export { default as useGenerations } from './useGenerations';
export { default as useServerStream } from './useServerStream';
export { default as useMessageHandler } from './useMessageHandler'; export { default as useMessageHandler } from './useMessageHandler';

View file

@ -51,7 +51,7 @@ const messagesSiblingIdxFamily = atomFamily({
const useConversation = () => { const useConversation = () => {
const setConversation = useSetRecoilState(conversation); const setConversation = useSetRecoilState(conversation);
const setMessages = useSetRecoilState<TMessagesAtom>(messages); const setMessages = useSetRecoilState<TMessagesAtom>(messages);
const setSubmission = useSetRecoilState<TSubmission | object | null>(submission.submission); const setSubmission = useSetRecoilState<TSubmission | null>(submission.submission);
const resetLatestMessage = useResetRecoilState(latestMessage); const resetLatestMessage = useResetRecoilState(latestMessage);
const _switchToConversation = ( const _switchToConversation = (
@ -73,7 +73,7 @@ const useConversation = () => {
setConversation(conversation); setConversation(conversation);
setMessages(messages); setMessages(messages);
setSubmission({}); setSubmission({} as TSubmission);
resetLatestMessage(); resetLatestMessage();
}; };

View file

@ -6,7 +6,7 @@ import { TPreset } from 'librechat-data-provider';
// an array of saved presets. // an array of saved presets.
// sample structure // sample structure
// [preset1, preset2, preset3] // [preset1, preset2, preset3]
const presets = atom({ const presets = atom<TPreset[]>({
key: 'presets', key: 'presets',
default: [], default: [],
}); });

View file

@ -2,7 +2,7 @@ import { TMessage } from 'librechat-data-provider';
import { atom, selector } from 'recoil'; import { atom, selector } from 'recoil';
import { buildTree } from '~/utils'; import { buildTree } from '~/utils';
const isSearchEnabled = atom({ const isSearchEnabled = atom<boolean | null>({
key: 'isSearchEnabled', key: 'isSearchEnabled',
default: null, default: null,
}); });

View file

@ -12,7 +12,7 @@ import { TSubmission } from 'librechat-data-provider';
// isRegenerate=false, // isRegenerate? // isRegenerate=false, // isRegenerate?
// } // }
const submission = atom<TSubmission | object | null>({ const submission = atom<TSubmission | null>({
key: 'submission', key: 'submission',
default: null, default: null,
}); });