Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
23 changes: 0 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/components/AccountNotifications.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import _ from 'lodash';
import { ChevronDownIcon, ChevronLeftIcon } from '@primer/octicons-react';

import { Notification } from '../typesGithub';
Expand All @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/components/AllRead.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { emojify } from 'react-emojione';

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

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

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

<h2 className="font-semibold text-xl mb-2 text-semibold">
No new notifications.
Expand Down
3 changes: 1 addition & 2 deletions src/components/Oops.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { emojify } from 'react-emojione';

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

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

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

<h2 className="font-semibold text-xl mb-2 text-semibold">
Something went wrong.
Expand Down
2 changes: 1 addition & 1 deletion src/components/__snapshots__/Oops.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`components/oops.tsx should render itself & its children 1`] = `
<h1
className="text-5xl mb-5"
>
😔
🤔
</h1>
<h2
className="font-semibold text-xl mb-2 text-semibold"
Expand Down
20 changes: 2 additions & 18 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,9 @@ export const Constants = {
// Storage
STORAGE_KEY: 'gitify-storage',

ALLREAD_EMOJIS: [
':wink:',
':tada:',
':tiger:',
':see_no_evil:',
':balloon:',
':confetti_ball:',
':clap:',
':circus_tent:',
':spaghetti:',
],
ALLREAD_EMOJIS: ['😉', '🎉', '🐯', '🙈', '🎈', '🎊', '👏', '🎪', '🍝'],

ERROR_EMOJIS: [
':pensive:',
':disappointed:',
':triumph:',
':scream:',
':cry:',
],
ERROR_EMOJIS: ['🤔', '😞', '😤', '😱', '😭'],
};

export default Constants;
1 change: 0 additions & 1 deletion src/utils/notifications.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from 'lodash';
import { ipcRenderer } from 'electron';

import { generateGitHubWebUrl, getCommentId } from './helpers';
Expand Down
2 changes: 0 additions & 2 deletions src/utils/remove-notification.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as _ from 'lodash';

import {
mockedSingleAccountNotifications,
mockedSingleNotification,
Expand Down
22 changes: 12 additions & 10 deletions src/utils/remove-notification.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import updateWith from 'lodash/updateWith';

import { AccountNotifications } from '../types';
import { Notification } from '../typesGithub';

export const removeNotification = (
id: string,
Expand All @@ -12,11 +9,16 @@ export const removeNotification = (
(accountNotifications) => 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;
};
22 changes: 11 additions & 11 deletions src/utils/remove-notifications.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import updateWith from 'lodash/updateWith';

import { AccountNotifications } from '../types';
import { Notification } from '../typesGithub';

export const removeNotifications = (
repoSlug: string,
Expand All @@ -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;
};