mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
added polling for receiving live messages
This commit is contained in:
1 parent
be5c038128
commit
c5b1e3d8c7
2 files changed
+22
-1
No files matched your search
@@ -7,10 +7,12 @@ import useMessages from "../../hooks/useMessages";
|
||||
import useModals from "../../hooks/useModals";
|
||||
import Conversation, { CONVERSATION_ELEMENT_ID } from "./Conversation";
|
||||
import MessageSkeletonList from "./MessageSkeletonList";
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
|
||||
const LARGE_HEADER_CHARS = 30;
|
||||
const MAX_HEADER_CHARS = 80;
|
||||
const MINIMUM_LOAD_TIME = 750;
|
||||
const MESSAGES_REFRESH_RATE = 5000;
|
||||
|
||||
export const MessageModal = () => {
|
||||
const classes = useStyles();
|
||||
@@ -42,6 +44,14 @@ export const MessageModal = () => {
|
||||
}
|
||||
}, [minimumLoadPassed, messages?.length]);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = window.setInterval(() => {
|
||||
if (!activeMessageGroup) return;
|
||||
Nui.send("phone:fetchMessages", { groupId: activeMessageGroup.groupId });
|
||||
}, MESSAGES_REFRESH_RATE);
|
||||
return () => window.clearInterval(interval);
|
||||
});
|
||||
|
||||
// we add a minimum (but short) load time here so that
|
||||
// there isn't a quick flash of loading and immediately
|
||||
// another flash to the tweets screen.
|
||||
|
||||
Reference in new issue
Block a user