Skip to content

Commit

Permalink
prevent conversation request if not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Oct 9, 2023
1 parent 434f8cf commit 898f953
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,22 @@ const BATCH_SIZE = 20;

let _scrollTop = 0;

const ConversationsHistorySidebar = (): JSX.Element | null => {
const { user } = useAuth();
const Drawer = styled(MDrawer, {
shouldForwardProp: (prop) => prop !== 'isSmallScreen'
})<{ open: boolean }>(({ open }) => ({
width: open ? DRAWER_WIDTH : 0,
'& .MuiDrawer-paper': {
position: 'inherit',
gap: 10,
display: 'flex',
padding: '0px 4px',
backgroundImage: 'none'
}
}));

const _ConversationsHistorySidebar = () => {
const isMobile = useMediaQuery('(max-width:800px)');

const pSettings = useRecoilValue(projectSettingsState);
const [conversations, setConversations] = useRecoilState(
conversationsHistoryState
);
Expand Down Expand Up @@ -137,10 +148,6 @@ const ConversationsHistorySidebar = (): JSX.Element | null => {
}
}, [isLoadingMore, shouldLoadMore]);

if (!pSettings?.dataPersistence || !user) {
return null;
}

return (
<>
<Drawer
Expand Down Expand Up @@ -209,17 +216,15 @@ const ConversationsHistorySidebar = (): JSX.Element | null => {
);
};

const Drawer = styled(MDrawer, {
shouldForwardProp: (prop) => prop !== 'isSmallScreen'
})<{ open: boolean }>(({ open }) => ({
width: open ? DRAWER_WIDTH : 0,
'& .MuiDrawer-paper': {
position: 'inherit',
gap: 10,
display: 'flex',
padding: '0px 4px',
backgroundImage: 'none'
const ConversationsHistorySidebar = () => {
const { user } = useAuth();
const pSettings = useRecoilValue(projectSettingsState);

if (!pSettings?.dataPersistence || !user) {
return null;
}
}));

return <_ConversationsHistorySidebar />;
};

export { ConversationsHistorySidebar };
5 changes: 4 additions & 1 deletion libs/components/hooks/useChat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ const useChat = () => {
[setSession, sessionId]
);

const connect = useCallback(debounce(_connect, 1000), [_connect]);
const connect = useCallback(
debounce(_connect, 1000, { leading: true, trailing: false }),
[_connect]
);

const disconnect = useCallback(() => {
if (session?.socket) {
Expand Down

0 comments on commit 898f953

Please sign in to comment.