This commit is contained in:
PxlLoewe
2025-04-29 21:35:27 -07:00
parent 0d7f0ad2b8
commit ee49bdde89
12 changed files with 93 additions and 92 deletions

View File

@@ -3,6 +3,8 @@ import { ChatMessage } from "@repo/db";
import { socket } from "dispatch/socket";
interface ChatStore {
reportTabOpen: boolean;
setReportTabOpen: (open: boolean) => void;
ownId: null | string;
selectedChat: string | null;
chatOpen: boolean;
@@ -19,7 +21,9 @@ interface ChatStore {
addMessage: (userId: string, message: ChatMessage) => void;
}
export const useChatStore = create<ChatStore>((set, get) => ({
export const useLeftMenuStore = create<ChatStore>((set, get) => ({
reportTabOpen: false,
setReportTabOpen: (open: boolean) => set({ reportTabOpen: open }),
ownId: null,
chatOpen: false,
selectedChat: null,
@@ -95,7 +99,7 @@ export const useChatStore = create<ChatStore>((set, get) => ({
socket.on(
"chat-message",
({ userId, message }: { userId: string; message: ChatMessage }) => {
const store = useChatStore.getState();
const store = useLeftMenuStore.getState();
console.log("chat-message", userId, message);
// Update the chat store with the new message
store.addMessage(userId, message);