fixing dat not updating with sent messages
This commit is contained in:
@@ -350,6 +350,9 @@ export default function AudioContextProvider({ children }) {
|
||||
messagesByTeamMate[selectedTeammate] &&
|
||||
messagesByTeamMate[selectedTeammate].length > 0
|
||||
) {
|
||||
console.log("playing from this cache");
|
||||
|
||||
console.log(messagesByTeamMate);
|
||||
setPlayerSrc(messagesByTeamMate[selectedTeammate][0].audioDataUrl);
|
||||
} else {
|
||||
toast("nothing to play");
|
||||
|
||||
@@ -208,6 +208,7 @@ export function TeamDashboardContextProvider({ children }) {
|
||||
// if the map contains the teammate userid already, then cool, just unshift to that array
|
||||
const newMap = { ...prevMap };
|
||||
if (newMessage.receiverUserId in prevMap) {
|
||||
// won't be in map if I am the receiver
|
||||
newMap[newMessage.receiverUserId] = [
|
||||
newMessage,
|
||||
...prevMap[newMessage.receiverUserId],
|
||||
@@ -218,6 +219,18 @@ export function TeamDashboardContextProvider({ children }) {
|
||||
newMap[newMessage.receiverUserId] = [newMessage];
|
||||
}
|
||||
|
||||
// todo: if I am the receiver, still want to put it in the right conversation
|
||||
if (newMessage.receiverUserId == currUser.uid) {
|
||||
if (newMessage.senderUserId in prevMap) {
|
||||
newMap[newMessage.senderUserId] = [
|
||||
newMessage,
|
||||
...prevMap[newMessage.senderUserId],
|
||||
];
|
||||
} else {
|
||||
newMap[newMessage.senderUserId] = [newMessage];
|
||||
}
|
||||
}
|
||||
|
||||
return newMap;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user