Skip to content

Commit

Permalink
fix: regression in delay notification state after tailwind animations
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 14, 2024
1 parent b4b622f commit 13c57df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
20 changes: 4 additions & 16 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ import {
ReadIcon,
TagIcon,
} from '@primer/octicons-react';
import {
type FC,
type MouseEvent,
useCallback,
useContext,
useState,
} from 'react';
import { type FC, type MouseEvent, useCallback, useContext } from 'react';
import { AppContext } from '../context/App';
import { IconColor } from '../types';
import type { Notification } from '../typesGitHub';
Expand Down Expand Up @@ -44,10 +38,8 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
markNotificationDone,
unsubscribeNotification,
} = useContext(AppContext);
const [animateExit, setAnimateExit] = useState(false);

const handleNotification = useCallback(() => {
setAnimateExit(true);
openNotification(notification);

if (settings.markAsDoneOnOpen) {
Expand Down Expand Up @@ -98,11 +90,9 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
return (
<div
id={notification.id}
className={cn(
'group flex border-b border-gray-100 bg-white px-3 py-2 hover:bg-gray-100 dark:border-gray-darker dark:bg-gray-dark dark:text-white dark:hover:bg-gray-darker',
animateExit &&
'translate-x-full opacity-0 transition duration-[350ms] ease-in-out',
)}
className={
'group flex border-b border-gray-100 bg-white px-3 py-2 hover:bg-gray-100 dark:border-gray-darker dark:bg-gray-dark dark:text-white dark:hover:bg-gray-darker'
}
>
<div
className={cn('mr-3 flex w-5 items-center justify-center', iconColor)}
Expand Down Expand Up @@ -218,7 +208,6 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
className="h-full hover:text-green-500 focus:outline-none"
title="Mark as Done"
onClick={() => {
setAnimateExit(true);
markNotificationDone(notification);
}}
>
Expand All @@ -239,7 +228,6 @@ export const NotificationRow: FC<IProps> = ({ notification }) => {
className="h-full hover:text-green-500 focus:outline-none"
title="Mark as Read"
onClick={() => {
setAnimateExit(true);
markNotificationRead(notification);
}}
>
Expand Down
1 change: 1 addition & 0 deletions src/context/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
settings.participating,
settings.showBots,
settings.detailedNotifications,
settings.delayNotificationState,
auth.accounts.length,
]);

Expand Down
3 changes: 3 additions & 0 deletions src/styles/gitify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ export const BUTTON_SIDEBAR_CLASS_NAME =
'flex justify-evenly items-center bg-transparent border-0 w-full text-sm text-white my-1 py-2 cursor-pointer hover:text-gray-500 focus:outline-none disabled:text-gray-500 disabled:cursor-default';

export const READ_NOTIFICATION_CLASS_NAME = 'opacity-50 dark:opacity-50';

export const ANIMATE_NOTIFICATION_CLASS_NAME =
'translate-x-full opacity-0 transition duration-[350ms] ease-in-out';
8 changes: 7 additions & 1 deletion src/utils/remove-notification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { READ_NOTIFICATION_CLASS_NAME } from '../styles/gitify';
import {
ANIMATE_NOTIFICATION_CLASS_NAME,
READ_NOTIFICATION_CLASS_NAME,
} from '../styles/gitify';
import type { AccountNotifications, SettingsState } from '../types';
import type { Notification } from '../typesGitHub';
import { getAccountUUID } from './auth/utils';
Expand All @@ -14,6 +17,9 @@ export const removeNotification = (
return notifications;
}

const notificationRow = document.getElementById(notification.id);
notificationRow.className += ` ${ANIMATE_NOTIFICATION_CLASS_NAME}`;

const notificationId = notification.id;

const accountIndex = notifications.findIndex(
Expand Down

0 comments on commit 13c57df

Please sign in to comment.