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

Loading…
Cancel
Save