@@ -22,6 +22,7 @@ import ListIcon from '@material-ui/icons/List';
22
22
import SearchIcon from '@material-ui/icons/Search' ;
23
23
import DashboardIcon from '@material-ui/icons/Dashboard' ;
24
24
import NotificationsIcon from '@material-ui/icons/Notifications' ;
25
+ import Badge from '@material-ui/core/Badge' ;
25
26
import PersonIcon from '@material-ui/icons/Person' ;
26
27
import UpdateIcon from '@material-ui/icons/Update' ;
27
28
// MODALS
@@ -38,6 +39,8 @@ import { DashboardContext } from '../context/DashboardContext';
38
39
39
40
import { ApplicationContext } from '../context/ApplicationContext' ;
40
41
42
+ import { CommsContext } from '../context/CommsContext' ;
43
+
41
44
// TYPESCRIPT
42
45
interface StyleProps {
43
46
root : BaseCSSProperties ;
@@ -47,6 +50,7 @@ type ClickEvent = React.MouseEvent<HTMLElement>;
47
50
const Occupied = React . memo ( ( ) => {
48
51
const { setServicesData } = useContext ( ApplicationContext ) ;
49
52
const { applications, getApplications, deleteApp, mode, getMode } = useContext ( DashboardContext ) ;
53
+ const { commsData, setCommsData, fetchCommsData } = useContext ( CommsContext ) ;
50
54
const [ open , setOpen ] = useState < boolean > ( false ) ;
51
55
const [ addOpen , setAddOpen ] = useState < boolean > ( false ) ;
52
56
const [ index , setIndex ] = useState < number > ( 0 ) ;
@@ -56,9 +60,14 @@ const Occupied = React.memo(() => {
56
60
const delRef = useRef < any > ( [ ] ) ;
57
61
useEffect ( ( ) => {
58
62
setServicesData ( [ ] ) ;
59
- getApplications ( ) ;
63
+ getApplications ( ) ;
64
+ // update communication data from last visited database
65
+ for ( const app of applications ) {
66
+ const temp = commsData ;
67
+ const newComm = fetchCommsData ( '' , true ) ;
68
+ setCommsData ( [ ...temp , newComm ] )
69
+ }
60
70
} , [ ] ) ;
61
-
62
71
63
72
// Ask user for deletetion confirmation
64
73
const confirmDelete = ( event : ClickEvent , app : string , i : number ) => {
@@ -185,7 +194,6 @@ const Occupied = React.memo(() => {
185
194
} ) ) ;
186
195
187
196
let classes = ( mode === 'light mode' ) ? useStylesLight ( { } as StyleProps ) : useStylesDark ( { } as StyleProps ) ;
188
- console . log ( applications )
189
197
return (
190
198
< div className = "entireArea" >
191
199
< div className = "dashboardArea" >
@@ -212,11 +220,14 @@ const Occupied = React.memo(() => {
212
220
< span className = "dashboardTooltip" > You have { applications . length } active databases</ span >
213
221
< DashboardIcon className = "navIcon" id = "dashboardIcon" />
214
222
</ div >
223
+
224
+
225
+ < div className = "notificationsIconArea" >
226
+ < span className = "notificationsTooltip" > You have { commsData . length } new alerts</ span >
227
+ < NotificationsIcon className = "navIcon" id = "notificationsIcon" />
228
+ < Badge badgeContent = { commsData . length } color = "secondary" />
229
+ </ div >
215
230
216
- < div className = "notificationsIconArea" >
217
- < span className = "notificationsTooltip" > You have no new alerts</ span >
218
- < NotificationsIcon className = "navIcon" id = "notificationsIcon" />
219
- </ div >
220
231
221
232
< div className = "personIconArea" >
222
233
< span className = "personTooltip" > You are not logged in</ span >
0 commit comments