Remove notificationchanges array

main
Joshua Sigona 3 years ago
parent db4a22d5cb
commit 8821babb9b
  1. 24
      src/App.js

@ -136,24 +136,12 @@ function App() {
.then((data)=>{ .then((data)=>{
if (data.data.length>0) { if (data.data.length>0) {
var newNotifications = [...notifications] var newNotifications = [...notifications]
for (var not of closedNotifications) {
newNotifications = newNotifications.filter((not2)=>not2.id!==not.id)
}
for (var dat of data.data) { for (var dat of data.data) {
var exists=false newNotifications.push(dat)
for (var not of newNotifications) {
if (not.id===dat.id) {
exists=true
break;
}
}
if (!exists) {
newNotifications.push(dat)
}
} }
console.log("New notification array: "+JSON.stringify(newNotifications)) console.log("New notification array: "+JSON.stringify(newNotifications))
setNotifications(newNotifications)
setNotificationLastUpdate(new Date()) setNotificationLastUpdate(new Date())
setNotifications(newNotifications)
} }
}) })
.catch((err)=>{ .catch((err)=>{
@ -237,10 +225,6 @@ function App() {
downloadData(d,0,d.length) downloadData(d,0,d.length)
setTotal(d.length) setTotal(d.length)
},[fileData]) },[fileData])
useEffect(()=>{
console.log(notifications)
},[notifications])
return ( return (
<Container className="bg-dark" fluid> <Container className="bg-dark" fluid>
@ -290,8 +274,8 @@ function App() {
} }
<div style={{pointerEvents:"none",position:"fixed",top:"0px",left:"0px",width:"100%",height:"100%"}}> <div style={{pointerEvents:"none",position:"fixed",top:"0px",left:"0px",width:"100%",height:"100%"}}>
<ToastContainer position="bottom-end"> <ToastContainer position="bottom-end">
{notifications.map((not)=>{ {notifications.map((not,i)=>{
return <Toast key={not.id} autohide delay={10000} onClose={()=>{var newArr = closedNotifications.push(not); setClosedNotifications(newArr)}} bg="primary"> return <Toast key={not.id} autohide delay={10000} onClose={()=>{var newArr = [...notifications]; newArr=newArr.splice(i,1); setNotifications(newArr)}} bg="primary">
<Toast.Header closeButton={true}> <Toast.Header closeButton={true}>
<span className="me-auto"> <span className="me-auto">
<strong>{not.username}</strong> <strong>{not.username}</strong>

Loading…
Cancel
Save