From 8821babb9b1cea5168a8e453905fb909f63dc884 Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Fri, 27 Aug 2021 06:43:24 +0900 Subject: [PATCH] Remove notificationchanges array --- src/App.js | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/App.js b/src/App.js index 12bf09d..fd6b13e 100644 --- a/src/App.js +++ b/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)=>{ @@ -237,10 +225,6 @@ function App() { downloadData(d,0,d.length) setTotal(d.length) },[fileData]) - - useEffect(()=>{ - console.log(notifications) - },[notifications]) return ( @@ -290,8 +274,8 @@ function App() { }
- {notifications.map((not)=>{ - return {var newArr = closedNotifications.push(not); setClosedNotifications(newArr)}} bg="primary"> + {notifications.map((not,i)=>{ + return {var newArr = [...notifications]; newArr=newArr.splice(i,1); setNotifications(newArr)}} bg="primary"> {not.username}