Skip to content

Commit e62aa37

Browse files
committed
chore: revert refresh block
1 parent d3e6d31 commit e62aa37

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

src/components/Sidebar.test.tsx

+1-23
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,17 @@ describe('components/Sidebar.tsx', () => {
105105
fetchNotifications.mockReset();
106106

107107
const enabledRefreshButton = 'Refresh Notifications';
108-
const disabledRefreshButton =
109-
'Please wait before manually refreshing again...';
110-
111-
// Refresh button should be enabled
112-
expect(screen.getByTitle(enabledRefreshButton)).toHaveProperty(
113-
'disabled',
114-
false,
115-
);
116-
expect(screen.queryByTitle(disabledRefreshButton)).toBeNull();
117108

118109
fireEvent.click(screen.getByTitle(enabledRefreshButton));
119110

120111
expect(fetchNotifications).toHaveBeenCalledTimes(1);
121112

122-
// Refresh button temporarily disabled
123-
expect(screen.queryByTitle(enabledRefreshButton)).toBeNull();
124-
expect(screen.getByTitle(disabledRefreshButton)).toHaveProperty(
125-
'disabled',
126-
true,
127-
);
128-
129113
act(() => {
130114
jest.advanceTimersByTime(Constants.FETCH_INTERVAL);
131115
return;
132116
});
133-
expect(fetchNotifications).toHaveBeenCalledTimes(2);
134117

135-
// Refresh button re-enabled
136-
expect(screen.getByTitle(enabledRefreshButton)).toHaveProperty(
137-
'disabled',
138-
false,
139-
);
140-
expect(screen.queryByTitle(disabledRefreshButton)).toBeNull();
118+
expect(fetchNotifications).toHaveBeenCalledTimes(2);
141119
});
142120

143121
it('go to the settings route', () => {

src/components/Sidebar.tsx

+2-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
useEffect,
1414
useMemo,
1515
useRef,
16-
useState,
1716
} from 'react';
1817
import { useLocation, useNavigate } from 'react-router-dom';
1918

@@ -27,8 +26,6 @@ export const Sidebar: FC = () => {
2726
const navigate = useNavigate();
2827
const location = useLocation();
2928

30-
const [recentlyRefreshed, setRecentlyRefreshed] = useState(false);
31-
3229
const { notifications, fetchNotifications, isLoggedIn, isFetching } =
3330
useContext(AppContext);
3431

@@ -60,7 +57,6 @@ export const Sidebar: FC = () => {
6057

6158
const { resetFetchInterval } = useFetchInterval(() => {
6259
if (isLoggedIn) {
63-
setRecentlyRefreshed(false);
6460
fetchNotifications();
6561
}
6662
}, Constants.FETCH_INTERVAL);
@@ -119,18 +115,13 @@ export const Sidebar: FC = () => {
119115
<button
120116
type="button"
121117
className={sidebarButtonClasses}
122-
title={
123-
recentlyRefreshed
124-
? 'Please wait before manually refreshing again...'
125-
: 'Refresh Notifications'
126-
}
118+
title="Refresh Notifications"
127119
onClick={() => {
128120
navigate('/', { replace: true });
129-
setRecentlyRefreshed(true);
130121
fetchNotifications();
131122
resetFetchInterval();
132123
}}
133-
disabled={isFetching || recentlyRefreshed}
124+
disabled={isFetching}
134125
>
135126
<SyncIcon
136127
size={16}

0 commit comments

Comments
 (0)