Skip to content

Commit

Permalink
Merge branch 'fix-ssr-and-csr-issue' of https://github.com/Sma1lboy/c…
Browse files Browse the repository at this point in the history
…odefox into fix-ssr-and-csr-issue
  • Loading branch information
NarwhalChen committed Jan 22, 2025
2 parents 66b658a + d06b911 commit 7ea4bc0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion backend/src/common/scalar/date.scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class DateScalar implements CustomScalar<number, Date> {
return value.getTime();
}


parseLiteral(ast: ValueNode): Date {
if (ast.kind === Kind.INT) {
return new Date(ast.value);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const useAuth = () => {
{
variables: {
input: {
token: "",
token: '',
},
},
skip: true,
Expand Down
11 changes: 4 additions & 7 deletions frontend/src/app/hooks/useChatStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ export function useChatStream({
variables: null,
});


const updateChatId = () => {
setCurrentChatId('');
setCurrentChatId('');
};

window.addEventListener('newchat', updateChatId);
window.addEventListener('newchat', updateChatId);

const [triggerChat] = useMutation(TRIGGER_CHAT, {
onCompleted: () => {
Expand All @@ -72,7 +71,7 @@ export function useChatStream({
setCurrentChatId(newChatId);
await startChatStream(newChatId, input);
window.history.pushState({}, '', `/?id=${newChatId}`);
console.log(`new chat: ${newChatId}`)
console.log(`new chat: ${newChatId}`);
},
onError: () => {
toast.error('Failed to create chat');
Expand Down Expand Up @@ -137,14 +136,13 @@ export function useChatStream({

const startChatStream = async (targetChatId: string, message: string) => {
try {

const input: ChatInput = {
chatId: targetChatId,
message,
model: selectedModel,
};
console.log(input);

setInput('');
setStreamStatus(StreamStatus.STREAMING);
setSubscription({
Expand All @@ -154,7 +152,6 @@ export function useChatStream({

await new Promise((resolve) => setTimeout(resolve, 100));
await triggerChat({ variables: { input } });

} catch (err) {
toast.error('Failed to start chat');
setStreamStatus(StreamStatus.IDLE);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/providers/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ export const AuthProvider = ({ children }: AuthProviderProps) => {

try {
const { data } = await checkToken({
variables: {
variables: {
input: {
token,
},
},
});
});

if (isMounted) {
if (!data?.checkToken) {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ function Sidebar({
id={chat.id}
title={chat.title}
isSelected={currentChatId === chat.id}
onSelect={() =>
window.history.replaceState({}, '', `/?id=${chat.id}`)}
onSelect={() =>
window.history.replaceState({}, '', `/?id=${chat.id}`)
}
refetchChats={onRefetch}
/>
))}
Expand Down

0 comments on commit 7ea4bc0

Please sign in to comment.