5 min notifications

main
Joshua Sigona 3 years ago
parent 6ae320c1c4
commit b66d0f26b6
  1. 15
      src/App.js

@ -24,6 +24,8 @@ const dataSplitters = [0,135,250,388]
const BACKEND_URL = "https://projectdivar.com:4505" const BACKEND_URL = "https://projectdivar.com:4505"
const NOTIFICATIONTIMEOUT = 300 //In seconds
function ItemGroup(p) { function ItemGroup(p) {
const { data } = p const { data } = p
const { contributor } = p const { contributor } = p
@ -39,15 +41,6 @@ function ItemGroup(p) {
})) }))
},[data]) },[data])
function findIndex(name,arr) {
for (var i=0;i<arr.length;i++) {
if (arr[i].name===name) {
console.log("Found "+name+" at position "+i)
return i
}
}
}
useEffect(()=>{ useEffect(()=>{
displayData.forEach((item)=>{ displayData.forEach((item)=>{
if (document.getElementById("field_"+item.id)) { if (document.getElementById("field_"+item.id)) {
@ -100,7 +93,7 @@ function Notification(p) {
const [show,setShow] = useState(true) const [show,setShow] = useState(true)
const { not } = p const { not } = p
return <Toast key={not.id} show={show} autohide delay={10000} onClose={()=>{setShow(false)}} bg={not.operation==="FINISH"?"success":not.operation==="INCREASE"?"primary":"warning"}> return <Toast key={not.id} show={show} autohide delay={NOTIFICATIONTIMEOUT*1000} onClose={()=>{setShow(false)}} bg={not.operation==="FINISH"?"success":not.operation==="INCREASE"?"primary":"warning"}>
<Toast.Header closeButton={true}> <Toast.Header closeButton={true}>
<span className="me-auto"> <span className="me-auto">
<strong>{not.username}</strong> <strong>{not.username}</strong>
@ -160,7 +153,7 @@ function App() {
useEffect(()=>{ useEffect(()=>{
const interval = setInterval(()=>{ const interval = setInterval(()=>{
setNotificationLastUpdate(new Date()-10000) setNotificationLastUpdate(new Date()-(NOTIFICATIONTIMEOUT*1000))
axios.get(BACKEND_URL+"/getNotifications?date="+encodeURIComponent(LZ(4,notificationLastUpdate.getUTCFullYear())+"-"+LZ(2,notificationLastUpdate.getUTCMonth()+1)+"-"+LZ(2,notificationLastUpdate.getUTCDate())+" "+LZ(2,notificationLastUpdate.getUTCHours())+":"+LZ(2,notificationLastUpdate.getUTCMinutes())+":"+LZ(2,notificationLastUpdate.getUTCSeconds())+"."+LZ(3,notificationLastUpdate.getUTCMilliseconds())+"+00")) axios.get(BACKEND_URL+"/getNotifications?date="+encodeURIComponent(LZ(4,notificationLastUpdate.getUTCFullYear())+"-"+LZ(2,notificationLastUpdate.getUTCMonth()+1)+"-"+LZ(2,notificationLastUpdate.getUTCDate())+" "+LZ(2,notificationLastUpdate.getUTCHours())+":"+LZ(2,notificationLastUpdate.getUTCMinutes())+":"+LZ(2,notificationLastUpdate.getUTCSeconds())+"."+LZ(3,notificationLastUpdate.getUTCMilliseconds())+"+00"))
.then((data)=>{ .then((data)=>{
if (data.data.length>0) { if (data.data.length>0) {

Loading…
Cancel
Save