Skip to content

Commit 25ac94a

Browse files
authored
chore: remove lodash and emojione (#675)
1 parent 4cac530 commit 25ac94a

11 files changed

+39
-78
lines changed

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@
101101
"electron-updater": "6.1.4",
102102
"final-form": "4.20.10",
103103
"history": "4.10.1",
104-
"lodash": "4.17.21",
105104
"menubar": "9.3.0",
106105
"nprogress": "0.2.0",
107106
"react": "18.2.0",
108107
"react-dom": "18.2.0",
109-
"react-emojione": "5.0.1",
110108
"react-final-form": "6.5.9",
111109
"react-router": "6.16.0",
112110
"react-router-dom": "6.16.0",
@@ -118,7 +116,6 @@
118116
"@testing-library/react": "14.0.0",
119117
"@testing-library/react-hooks": "8.0.1",
120118
"@types/jest": "29.5.5",
121-
"@types/lodash": "4.14.199",
122119
"@types/node": "18.18.0",
123120
"@types/react": "18.2.28",
124121
"@types/react-router-dom": "5.3.3",

pnpm-lock.yaml

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AccountNotifications.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import _ from 'lodash';
32
import { ChevronDownIcon, ChevronLeftIcon } from '@primer/octicons-react';
43

54
import { Notification } from '../typesGithub';
@@ -14,10 +13,17 @@ interface IProps {
1413
export const AccountNotifications = (props: IProps) => {
1514
const { hostname, showAccountHostname, notifications } = props;
1615

17-
const groupedNotifications = _(notifications)
18-
.groupBy((obj) => obj.repository.full_name)
19-
.sortBy((_, key) => key)
20-
.value();
16+
const groupedNotifications = Object.values(
17+
notifications.reduce(
18+
(acc: { [key: string]: Notification[] }, notification) => {
19+
const key = notification.repository.full_name;
20+
if (!acc[key]) acc[key] = [];
21+
acc[key].push(notification);
22+
return acc;
23+
},
24+
{},
25+
),
26+
);
2127

2228
const Chevron = notifications.length > 0 ? ChevronDownIcon : ChevronLeftIcon;
2329

src/components/AllRead.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { emojify } from 'react-emojione';
32

43
import { Constants } from '../utils/constants';
54

@@ -14,7 +13,7 @@ export const AllRead = () => {
1413

1514
return (
1615
<div className="flex flex-1 flex-col justify-center items-center p-4 bg-white dark:bg-gray-dark text-black dark:text-white">
17-
<h1 className="text-5xl mb-5">{emojify(emoji, { output: 'unicode' })}</h1>
16+
<h1 className="text-5xl mb-5">{emoji}</h1>
1817

1918
<h2 className="font-semibold text-xl mb-2 text-semibold">
2019
No new notifications.

src/components/Oops.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { emojify } from 'react-emojione';
32

43
import { Constants } from '../utils/constants';
54

@@ -14,7 +13,7 @@ export const Oops = () => {
1413

1514
return (
1615
<div className="flex flex-1 flex-col justify-center items-center p-4 bg-white dark:bg-gray-dark text-black dark:text-white">
17-
<h1 className="text-5xl mb-5">{emojify(emoji, { output: 'unicode' })}</h1>
16+
<h1 className="text-5xl mb-5">{emoji}</h1>
1817

1918
<h2 className="font-semibold text-xl mb-2 text-semibold">
2019
Something went wrong.

src/components/__snapshots__/Oops.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`components/oops.tsx should render itself & its children 1`] = `
77
<h1
88
className="text-5xl mb-5"
99
>
10-
😔
10+
🤔
1111
</h1>
1212
<h2
1313
className="font-semibold text-xl mb-2 text-semibold"

src/utils/constants.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,9 @@ export const Constants = {
1313
// Storage
1414
STORAGE_KEY: 'gitify-storage',
1515

16-
ALLREAD_EMOJIS: [
17-
':wink:',
18-
':tada:',
19-
':tiger:',
20-
':see_no_evil:',
21-
':balloon:',
22-
':confetti_ball:',
23-
':clap:',
24-
':circus_tent:',
25-
':spaghetti:',
26-
],
16+
ALLREAD_EMOJIS: ['😉', '🎉', '🐯', '🙈', '🎈', '🎊', '👏', '🎪', '🍝'],
2717

28-
ERROR_EMOJIS: [
29-
':pensive:',
30-
':disappointed:',
31-
':triumph:',
32-
':scream:',
33-
':cry:',
34-
],
18+
ERROR_EMOJIS: ['🤔', '😞', '😤', '😱', '😭'],
3519
};
3620

3721
export default Constants;

src/utils/notifications.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as _ from 'lodash';
21
import { ipcRenderer } from 'electron';
32

43
import { generateGitHubWebUrl, getCommentId } from './helpers';

src/utils/remove-notification.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as _ from 'lodash';
2-
31
import {
42
mockedSingleAccountNotifications,
53
mockedSingleNotification,

src/utils/remove-notification.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import updateWith from 'lodash/updateWith';
2-
31
import { AccountNotifications } from '../types';
4-
import { Notification } from '../typesGithub';
52

63
export const removeNotification = (
74
id: string,
@@ -12,11 +9,16 @@ export const removeNotification = (
129
(accountNotifications) => accountNotifications.hostname === hostname,
1310
);
1411

15-
return updateWith(
16-
[...notifications],
17-
`[${accountIndex}][notifications]`,
18-
(accNotifications: Notification[] = []) => {
19-
return accNotifications.filter((notification) => notification.id !== id);
20-
},
21-
);
12+
if (accountIndex !== -1) {
13+
const updatedNotifications = [...notifications];
14+
updatedNotifications[accountIndex] = {
15+
...updatedNotifications[accountIndex],
16+
notifications: updatedNotifications[accountIndex].notifications.filter(
17+
(notification) => notification.id !== id,
18+
),
19+
};
20+
return updatedNotifications;
21+
}
22+
23+
return notifications;
2224
};

0 commit comments

Comments
 (0)