wip: refactor chats to use zustand

This commit is contained in:
Ren Amamiya
2023-05-27 12:14:30 +07:00
parent 671b857077
commit 79e948ac05
21 changed files with 229 additions and 278 deletions

View File

@@ -1,14 +0,0 @@
import { atom } from "jotai";
import { atomWithReset } from "jotai/utils";
export const chatMessagesAtom = atomWithReset([]);
export const sortedChatMessagesAtom = atom((get) => {
const messages = get(chatMessagesAtom);
return messages.sort(
(x: { created_at: number }, y: { created_at: number }) =>
x.created_at - y.created_at,
);
});
// chat content
export const chatContentAtom = atomWithReset("");