fixes #118
This commit is contained in:
@@ -19,6 +19,7 @@ interface ChatStore {
|
||||
sendMessage: (userId: string, message: string) => Promise<void>;
|
||||
addChat: (userId: string, name: string) => void;
|
||||
addMessage: (userId: string, message: ChatMessage) => void;
|
||||
removeChat: (userId: string) => void;
|
||||
}
|
||||
|
||||
export const useLeftMenuStore = create<ChatStore>((set, get) => ({
|
||||
@@ -37,6 +38,15 @@ export const useLeftMenuStore = create<ChatStore>((set, get) => ({
|
||||
setChatNotification(chatId, false); // Set notification to false when chat is selected
|
||||
}
|
||||
},
|
||||
removeChat: (userId: string) => {
|
||||
const { chats, setSelectedChat, selectedChat } = get();
|
||||
const newChats = { ...chats };
|
||||
delete newChats[userId];
|
||||
set({ chats: newChats });
|
||||
if (selectedChat === userId) {
|
||||
setSelectedChat(null);
|
||||
}
|
||||
},
|
||||
setOwnId: (id: string) => set({ ownId: id }),
|
||||
chats: {},
|
||||
sendMessage: (userId: string, message: string) => {
|
||||
|
||||
Reference in New Issue
Block a user