dev
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user