generated from lucien/api-template
add: added messages autorefresh
This commit is contained in:
parent
e0efe57f5c
commit
15b2c5df19
2 changed files with 22 additions and 0 deletions
|
@ -64,6 +64,17 @@ export default function ChannelPage() {
|
||||||
});
|
});
|
||||||
}, [name]);
|
}, [name]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const id = setInterval(() => {
|
||||||
|
axios
|
||||||
|
.get("/api/lastmessages").then((res) => {
|
||||||
|
setMessages(res.data)
|
||||||
|
})
|
||||||
|
}, 5000)
|
||||||
|
|
||||||
|
return () => { clearInterval(id) }
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!channel || !messages) {
|
if (!channel || !messages) {
|
||||||
return <div>Loading...</div>;
|
return <div>Loading...</div>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,17 @@ export default function UserPage() {
|
||||||
});
|
});
|
||||||
}, [username]);
|
}, [username]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const id = setInterval(() => {
|
||||||
|
axios
|
||||||
|
.get("/api/lastmessages").then((res) => {
|
||||||
|
setMessages(res.data)
|
||||||
|
})
|
||||||
|
}, 5000)
|
||||||
|
|
||||||
|
return () => { clearInterval(id) }
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return <div>Loading...</div>;
|
return <div>Loading...</div>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue