Skip to content

Commit

Permalink
Use mutate()
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric committed Sep 29, 2023
1 parent 8a90c05 commit b12941f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions front/hooks/useEventSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export function useEventSource(
};

es.onerror = (event) => {
console.error('useEventSource.onerror()', event)
console.error("useEventSource.onerror()", event);
errorCount.current += 1;
if (errorCount.current >= 3) {
console.log('too many errors, not reconnecting..')
console.log("too many errors, not reconnecting..");
setIsError(new Error("Too many errors, closing connection."));
es.close();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function handler(
}
res.write("data: done\n\n");
// @ts-expect-error - We need it for streaming but it does not exists in the types.
res.flush();
res.flush();

res.end();
return;
Expand Down
4 changes: 4 additions & 0 deletions front/pages/w/[wId]/assistant/[cId]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GetServerSideProps, InferGetServerSidePropsType } from "next";
import { useRouter } from "next/router";
import { mutate } from "swr";

import Conversation from "@app/components/assistant/conversation/Conversation";
import { ConversationTitle } from "@app/components/assistant/conversation/ConversationTitle";
Expand Down Expand Up @@ -81,6 +82,9 @@ export default function AssistantConversation({
window.alert(`Error creating message: ${data.error.message}`);
return;
}
await mutate(
`/api/w/${owner.sId}/assistant/conversations/${conversationId}/messages`
);
};

const handdleDeleteConversation = async () => {
Expand Down

0 comments on commit b12941f

Please sign in to comment.