Skip to content

Commit daa6b60

Browse files
authored
refactor: remove now redundant mark as read on click functionality (#713)
* refactor: remove now redundant `mark as read on click` functionality * refactor: remove now redundant `mark as read on click` functionality * refactor: remove now redundant `mark as read on click` functionality
1 parent 76d4211 commit daa6b60

File tree

10 files changed

+3
-94
lines changed

10 files changed

+3
-94
lines changed

Diff for: src/__mocks__/mock-state.ts

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const mockSettings: SettingsState = {
1616
participating: false,
1717
playSound: true,
1818
showNotifications: true,
19-
markOnClick: false,
2019
openAtStartup: false,
2120
appearance: Appearance.SYSTEM,
2221
colors: false,

Diff for: src/components/NotificationRow.test.tsx

+2-27
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('components/Notification.js', () => {
4141
const { getByRole } = render(
4242
<AppContext.Provider
4343
value={{
44-
settings: { ...mockSettings, markOnClick: true },
44+
settings: mockSettings,
4545
markNotification,
4646
accounts: mockAccounts,
4747
}}
@@ -54,31 +54,6 @@ describe('components/Notification.js', () => {
5454
expect(shell.openExternal).toHaveBeenCalledTimes(1);
5555
});
5656

57-
it('should open a notification in browser & mark it as read', () => {
58-
const markNotification = jest.fn();
59-
60-
const props = {
61-
notification: mockedSingleNotification,
62-
hostname: 'github.com',
63-
};
64-
65-
const { getByRole } = render(
66-
<AppContext.Provider
67-
value={{
68-
settings: { ...mockSettings, markOnClick: true },
69-
markNotification,
70-
accounts: mockAccounts,
71-
}}
72-
>
73-
<NotificationRow {...props} />
74-
</AppContext.Provider>,
75-
);
76-
77-
fireEvent.click(getByRole('main'));
78-
expect(shell.openExternal).toHaveBeenCalledTimes(1);
79-
expect(markNotification).toHaveBeenCalledTimes(1);
80-
});
81-
8257
it('should mark a notification as read', () => {
8358
const markNotification = jest.fn();
8459

@@ -90,7 +65,7 @@ describe('components/Notification.js', () => {
9065
const { getByTitle } = render(
9166
<AppContext.Provider
9267
value={{
93-
settings: { ...mockSettings, markOnClick: false },
68+
settings: mockSettings,
9469
accounts: mockAccounts,
9570
}}
9671
>

Diff for: src/components/NotificationRow.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ export const NotificationRow: React.FC<IProps> = ({
2525

2626
const pressTitle = useCallback(() => {
2727
openBrowser();
28-
29-
if (settings.markOnClick) {
30-
markNotification(notification.id, hostname);
31-
}
3228
}, [settings]);
3329

3430
const openBrowser = useCallback(

Diff for: src/components/Sidebar.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('components/Sidebar.tsx', () => {
3535
const tree = TestRenderer.create(
3636
<AppContext.Provider
3737
value={{
38-
settings: { ...mockSettings },
38+
settings: mockSettings,
3939
notifications: mockedAccountNotifications,
4040
}}
4141
>

Diff for: src/context/App.test.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ describe('context/App.tsx', () => {
259259
{ enterpriseAccounts: [], token: null, user: null },
260260
{
261261
appearance: 'SYSTEM',
262-
markOnClick: false,
263262
openAtStartup: false,
264263
participating: true,
265264
playSound: true,
@@ -297,7 +296,6 @@ describe('context/App.tsx', () => {
297296
{ enterpriseAccounts: [], token: null, user: null },
298297
{
299298
appearance: 'SYSTEM',
300-
markOnClick: false,
301299
openAtStartup: true,
302300
participating: false,
303301
playSound: true,

Diff for: src/context/App.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export const defaultSettings: SettingsState = {
3434
participating: false,
3535
playSound: true,
3636
showNotifications: true,
37-
markOnClick: false,
3837
openAtStartup: false,
3938
appearance: Appearance.SYSTEM,
4039
colors: false,

Diff for: src/routes/Settings.test.tsx

-28
Original file line numberDiff line numberDiff line change
@@ -182,34 +182,6 @@ describe('routes/Settings.tsx', () => {
182182
expect(updateSetting).toHaveBeenCalledWith('showNotifications', false);
183183
});
184184

185-
it('should toggle the onClickMarkAsRead checkbox', async () => {
186-
let getByLabelText;
187-
188-
await act(async () => {
189-
const { getByLabelText: getByLabelTextLocal } = render(
190-
<AppContext.Provider
191-
value={{
192-
settings: mockSettings,
193-
accounts: mockAccounts,
194-
updateSetting,
195-
}}
196-
>
197-
<MemoryRouter>
198-
<SettingsRoute />
199-
</MemoryRouter>
200-
</AppContext.Provider>,
201-
);
202-
getByLabelText = getByLabelTextLocal;
203-
});
204-
205-
fireEvent.click(getByLabelText('Mark as read on click'), {
206-
target: { checked: true },
207-
});
208-
209-
expect(updateSetting).toHaveBeenCalledTimes(1);
210-
expect(updateSetting).toHaveBeenCalledWith('markOnClick', false);
211-
});
212-
213185
it('should toggle the openAtStartup checkbox', async () => {
214186
let getByLabelText;
215187

Diff for: src/routes/Settings.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ export const SettingsRoute: React.FC = () => {
139139
updateSetting('showNotifications', evt.target.checked)
140140
}
141141
/>
142-
<FieldCheckbox
143-
name="onClickMarkAsRead"
144-
label="Mark as read on click"
145-
checked={settings.markOnClick}
146-
onChange={(evt) => updateSetting('markOnClick', evt.target.checked)}
147-
/>
148142
{!isLinux && (
149143
<FieldCheckbox
150144
name="openAtStartUp"

Diff for: src/routes/__snapshots__/Settings.test.tsx.snap

-23
Original file line numberDiff line numberDiff line change
@@ -230,29 +230,6 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `
230230
</label>
231231
</div>
232232
</div>
233-
<div
234-
class="flex items-start mt-1 mb-3"
235-
>
236-
<div
237-
class="flex items-center h-5"
238-
>
239-
<input
240-
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded"
241-
id="onClickMarkAsRead"
242-
type="checkbox"
243-
/>
244-
</div>
245-
<div
246-
class="ml-3 text-sm"
247-
>
248-
<label
249-
class="font-medium text-gray-700 dark:text-gray-200"
250-
for="onClickMarkAsRead"
251-
>
252-
Mark as read on click
253-
</label>
254-
</div>
255-
</div>
256233
<div
257234
class="flex items-start mt-1 mb-3"
258235
>

Diff for: src/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export interface SettingsState {
1010
participating: boolean;
1111
playSound: boolean;
1212
showNotifications: boolean;
13-
markOnClick: boolean;
1413
openAtStartup: boolean;
1514
appearance: Appearance;
1615
colors: boolean;

0 commit comments

Comments
 (0)