diff --git a/contexts/audioContext.tsx b/contexts/audioContext.tsx index 67de7b1..748422f 100644 --- a/contexts/audioContext.tsx +++ b/contexts/audioContext.tsx @@ -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"); diff --git a/contexts/teamDashboardContext.tsx b/contexts/teamDashboardContext.tsx index d572f33..3035bd1 100644 --- a/contexts/teamDashboardContext.tsx +++ b/contexts/teamDashboardContext.tsx @@ -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; }); }