chat reloads with the selected team's chats

This commit is contained in:
Carter 2026-02-25 13:29:38 -06:00
parent 0ea31c81e4
commit c79c6baa1f

View file

@ -77,35 +77,42 @@ export default function Chat(props: Props) {
}; };
useEffect(() => { useEffect(() => {
loadChats() setChats([]);
}, []); setLoaded(false);
setLoading(false);
setTotalMessages(0);
}, [objectKey]);
useEffect(() => {
if (chats.length === 0 && !loaded) {
loadChats();
}
}, [objectKey, chats, loaded]);
const loadMore = () => { const loadMore = () => {
loadChats(); loadChats();
}; };
return ( return (
<React.Fragment> <Box className={classes.chatContainer}>
<Box sx={{ flex: 1, overflowY: "hidden", minHeight: 0 }}>
{loading && !loaded ? ( {loading && !loaded ? (
<Box width="100%" height="100%" alignContent={"center"} textAlign={"center"} > <Box width="100%" height="100%" alignContent="center" textAlign="center">
<CircularProgress /> <CircularProgress />
</Box> </Box>
) : ( ) : (
<Box className={classes.chatContainer}>
<Box sx={{ flex: 1, overflowY: "hidden", minHeight: 0 }}>
<ChatOutput <ChatOutput
totalMessages={totalMessages} totalMessages={totalMessages}
messages={chats} messages={chats}
removeNoteMethod={removeNote} removeNoteMethod={removeNote}
loadMore={loadMore} loadMore={loadMore}
/> />
)}
</Box> </Box>
<Box style={{ flexShrink: 0 }}> <Box style={{ flexShrink: 0 }}>
<Divider /> <Divider />
<ChatInput newNoteMethod={showNewNotes} objectKey={objectKey} type={type} /> <ChatInput newNoteMethod={showNewNotes} objectKey={objectKey} type={type} />
</Box> </Box>
</Box> </Box>
)}
</React.Fragment>
); );
} }