Merge pull request #11 from owncast/jv/reload-chat
Reload chat messages after FETCH_INTERVAL
This commit is contained in:
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|||||||
import { ColumnsType } from 'antd/es/table';
|
import { ColumnsType } from 'antd/es/table';
|
||||||
import format from 'date-fns/format'
|
import format from 'date-fns/format'
|
||||||
|
|
||||||
import { CHAT_HISTORY, fetchData, UPDATE_CHAT_MESSGAE_VIZ } from "../utils/apis";
|
import { CHAT_HISTORY, fetchData, FETCH_INTERVAL, UPDATE_CHAT_MESSGAE_VIZ } from "../utils/apis";
|
||||||
import { MessageType } from '../types/chat';
|
import { MessageType } from '../types/chat';
|
||||||
import { isEmptyObject } from "../utils/format";
|
import { isEmptyObject } from "../utils/format";
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ export default function Chat() {
|
|||||||
const [bulkOutcome, setBulkOutcome] = useState(null);
|
const [bulkOutcome, setBulkOutcome] = useState(null);
|
||||||
const [bulkAction, setBulkAction] = useState('');
|
const [bulkAction, setBulkAction] = useState('');
|
||||||
let outcomeTimeout = null;
|
let outcomeTimeout = null;
|
||||||
|
let chatReloadInterval = null;
|
||||||
|
|
||||||
const getInfo = async () => {
|
const getInfo = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -59,8 +60,14 @@ export default function Chat() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getInfo();
|
getInfo();
|
||||||
|
|
||||||
|
chatReloadInterval = setInterval(() => {
|
||||||
|
getInfo();
|
||||||
|
}, FETCH_INTERVAL);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
clearTimeout(outcomeTimeout);
|
clearTimeout(outcomeTimeout);
|
||||||
|
clearTimeout(chatReloadInterval);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
width: 3rem;
|
width: 3rem;
|
||||||
padding: 0.25rem;
|
padding: 0.25rem;
|
||||||
}
|
}
|
||||||
|
p {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user