Deine Commit-Nachricht
This commit is contained in:
@@ -38,6 +38,11 @@ export const Chat = () => {
|
||||
refetchInterval: 10000,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if(!session.data?.user.id) return;
|
||||
setOwnId(session.data?.user.id);
|
||||
}, [session.data?.user.id]);
|
||||
|
||||
const filteredDispatcher = dispatcher?.filter((d) => d.userId !== session.data?.user.id);
|
||||
const filteredAircrafts = aircrafts?.filter((a) => a.userId !== session.data?.user.id);
|
||||
|
||||
|
||||
@@ -35,13 +35,24 @@ export const useLeftMenuStore = create<ChatStore>((set, get) => ({
|
||||
chats: {},
|
||||
sendMessage: (userId: string, message: string) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatchSocket.emit("send-message", { userId, message }, ({ error }: { error?: string }) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
if(dispatchSocket.connected){
|
||||
|
||||
dispatchSocket.emit("send-message", { userId, message }, ({ error }: { error?: string }) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
} else if(pilotSocket.connected){
|
||||
pilotSocket.emit("send-message", { userId, message }, ({ error }: { error?: string }) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
addChat: (userId, name) => {
|
||||
|
||||
Reference in New Issue
Block a user