diff --git a/package.json b/package.json index abbd6b7e1..4aa7d9492 100644 --- a/package.json +++ b/package.json @@ -100,12 +100,10 @@ "electron-updater": "6.1.4", "final-form": "4.20.10", "history": "4.10.1", - "lodash": "4.17.21", "menubar": "9.3.0", "nprogress": "0.2.0", "react": "18.2.0", "react-dom": "18.2.0", - "react-emojione": "5.0.1", "react-final-form": "6.5.9", "react-router": "6.16.0", "react-router-dom": "6.16.0", @@ -117,7 +115,6 @@ "@testing-library/react": "14.0.0", "@testing-library/react-hooks": "8.0.1", "@types/jest": "29.5.5", - "@types/lodash": "4.14.199", "@types/node": "18.18.0", "@types/react": "18.2.28", "@types/react-router-dom": "5.3.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c40ac813..bf269a2a1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,9 +26,6 @@ dependencies: history: specifier: 4.10.1 version: 4.10.1 - lodash: - specifier: 4.17.21 - version: 4.17.21 menubar: specifier: 9.3.0 version: 9.3.0(electron@13.1.7) @@ -41,9 +38,6 @@ dependencies: react-dom: specifier: 18.2.0 version: 18.2.0(react@18.2.0) - react-emojione: - specifier: 5.0.1 - version: 5.0.1(react-dom@18.2.0)(react@18.2.0) react-final-form: specifier: 6.5.9 version: 6.5.9(final-form@4.20.10)(react@18.2.0) @@ -73,9 +67,6 @@ devDependencies: '@types/jest': specifier: 29.5.5 version: 29.5.5 - '@types/lodash': - specifier: 4.14.199 - version: 4.14.199 '@types/node': specifier: 18.18.0 version: 18.18.0 @@ -1102,10 +1093,6 @@ packages: dependencies: '@types/node': 18.18.0 - /@types/lodash@4.14.199: - resolution: {integrity: sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==} - dev: true - /@types/ms@0.7.31: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} dev: true @@ -4702,16 +4689,6 @@ packages: react: 18.2.0 scheduler: 0.23.0 - /react-emojione@5.0.1(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-sjI6k8uQ14rWENYoAb+2BFQGLBt/cpLDJJNhnZvdFJytAJijhv+JmbmyyrfQPdyID0Cs4N8XFqnek0xq6POwGA==} - peerDependencies: - react: ^16 - react-dom: ^16 - dependencies: - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - dev: false - /react-error-boundary@3.1.4(react@18.2.0): resolution: {integrity: sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA==} engines: {node: '>=10', npm: '>=6'} diff --git a/src/components/AccountNotifications.tsx b/src/components/AccountNotifications.tsx index bd2e9e82f..e28cfaffc 100644 --- a/src/components/AccountNotifications.tsx +++ b/src/components/AccountNotifications.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import _ from 'lodash'; import { ChevronDownIcon, ChevronLeftIcon } from '@primer/octicons-react'; import { Notification } from '../typesGithub'; @@ -14,10 +13,17 @@ interface IProps { export const AccountNotifications = (props: IProps) => { const { hostname, showAccountHostname, notifications } = props; - const groupedNotifications = _(notifications) - .groupBy((obj) => obj.repository.full_name) - .sortBy((_, key) => key) - .value(); + const groupedNotifications = Object.values( + notifications.reduce( + (acc: { [key: string]: Notification[] }, notification) => { + const key = notification.repository.full_name; + if (!acc[key]) acc[key] = []; + acc[key].push(notification); + return acc; + }, + {}, + ), + ); const Chevron = notifications.length > 0 ? ChevronDownIcon : ChevronLeftIcon; diff --git a/src/components/AllRead.tsx b/src/components/AllRead.tsx index 176369d5f..a15488c6f 100644 --- a/src/components/AllRead.tsx +++ b/src/components/AllRead.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { emojify } from 'react-emojione'; import { Constants } from '../utils/constants'; @@ -14,7 +13,7 @@ export const AllRead = () => { return (
-

{emojify(emoji, { output: 'unicode' })}

+

{emoji}

No new notifications. diff --git a/src/components/Oops.tsx b/src/components/Oops.tsx index 4285630b7..3e1dfbf66 100644 --- a/src/components/Oops.tsx +++ b/src/components/Oops.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { emojify } from 'react-emojione'; import { Constants } from '../utils/constants'; @@ -14,7 +13,7 @@ export const Oops = () => { return (
-

{emojify(emoji, { output: 'unicode' })}

+

{emoji}

Something went wrong. diff --git a/src/components/__snapshots__/Oops.test.tsx.snap b/src/components/__snapshots__/Oops.test.tsx.snap index 0fa863208..c6ef9f63f 100644 --- a/src/components/__snapshots__/Oops.test.tsx.snap +++ b/src/components/__snapshots__/Oops.test.tsx.snap @@ -7,7 +7,7 @@ exports[`components/oops.tsx should render itself & its children 1`] = `

- 😔 + 🤔

accountNotifications.hostname === hostname, ); - return updateWith( - [...notifications], - `[${accountIndex}][notifications]`, - (accNotifications: Notification[] = []) => { - return accNotifications.filter((notification) => notification.id !== id); - }, - ); + if (accountIndex !== -1) { + const updatedNotifications = [...notifications]; + updatedNotifications[accountIndex] = { + ...updatedNotifications[accountIndex], + notifications: updatedNotifications[accountIndex].notifications.filter( + (notification) => notification.id !== id, + ), + }; + return updatedNotifications; + } + + return notifications; }; diff --git a/src/utils/remove-notifications.ts b/src/utils/remove-notifications.ts index 47bb6078d..dcfb6bbfc 100644 --- a/src/utils/remove-notifications.ts +++ b/src/utils/remove-notifications.ts @@ -1,7 +1,4 @@ -import updateWith from 'lodash/updateWith'; - import { AccountNotifications } from '../types'; -import { Notification } from '../typesGithub'; export const removeNotifications = ( repoSlug: string, @@ -12,13 +9,16 @@ export const removeNotifications = ( (accountNotifications) => accountNotifications.hostname === hostname, ); - return updateWith( - [...notifications], - `[${accountIndex}][notifications]`, - (accNotifications: Notification[] = []) => { - return accNotifications.filter( + if (accountIndex !== -1) { + const updatedNotifications = [...notifications]; + updatedNotifications[accountIndex] = { + ...updatedNotifications[accountIndex], + notifications: updatedNotifications[accountIndex].notifications.filter( (notification) => notification.repository.full_name !== repoSlug, - ); - }, - ); + ), + }; + return updatedNotifications; + } + + return notifications; };