1
1
import * as Octicons from '@primer/octicons-react' ;
2
2
import { ipcRenderer , shell } from 'electron' ;
3
3
import React , { useCallback , useContext , useMemo } from 'react' ;
4
- import { useHistory } from 'react-router-dom' ;
4
+ import { useHistory , useLocation } from 'react-router-dom' ;
5
5
6
6
import { Logo } from '../components/Logo' ;
7
7
import { AppContext } from '../context/App' ;
@@ -12,6 +12,7 @@ import { Constants } from '../utils/constants';
12
12
13
13
export const Sidebar : React . FC = ( ) => {
14
14
const history = useHistory ( ) ;
15
+ const location = useLocation ( ) ;
15
16
16
17
const { isLoggedIn } = useContext ( AppContext ) ;
17
18
const { notifications, fetchNotifications } = useContext ( AppContext ) ;
@@ -64,15 +65,24 @@ export const Sidebar: React.FC = () => {
64
65
< >
65
66
< button
66
67
className = { footerButtonClasses }
67
- onClick = { fetchNotifications }
68
+ onClick = { ( ) => {
69
+ history . replace ( '/' ) ;
70
+ fetchNotifications ( ) ;
71
+ } }
68
72
aria-label = "Refresh Notifications"
69
73
>
70
74
< IconRefresh className = "w-3.5 h-3.5" />
71
75
</ button >
72
76
73
77
< button
74
78
className = { footerButtonClasses }
75
- onClick = { ( ) => history . push ( '/settings' ) }
79
+ onClick = { ( ) => {
80
+ if ( location . pathname . startsWith ( '/settings' ) ) {
81
+ history . replace ( '/' ) ;
82
+ } else {
83
+ history . push ( '/settings' ) ;
84
+ }
85
+ } }
76
86
aria-label = "Settings"
77
87
>
78
88
< IconCog className = "w-4 h-4" />
0 commit comments