Skip to content

Commit

Permalink
전체읽음 바로 반영되지 않는 오류 수정 (#659)
Browse files Browse the repository at this point in the history
* fix: 전체 읽음 오류 수정

* style: 불필요한 콘솔로그 삭제
  • Loading branch information
gyeongza authored Oct 11, 2023
1 parent d67ad7e commit 4cd8bbd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 57 deletions.
1 change: 0 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if (gaTrackingId) {

const history = createBrowserHistory();
history.listen((response: { location: { pathname: string } }) => {
console.log(response.location.pathname);
ReactGA.set({ page: response.location.pathname });
ReactGA.pageview(response.location.pathname);
});
Expand Down
50 changes: 0 additions & 50 deletions frontend/src/components/LoginError.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ import { useNotificationCheck } from '@/hooks/query/useNotificationCheck';

interface Props {
notificationList: Notification[];
checkIsAllRead: () => void;
}

const NotificationDropdown = ({ notificationList }: Props) => {
const NotificationDropdown = ({ notificationList, checkIsAllRead }: Props) => {
const { mutate: deleteNotification } = useNotificationDelete();
const { mutate: patchNotificationCheck } = useNotificationCheck();
const { goToRunnerMyPage } = usePageRouter();

const handlePostClick = (notificationId: number) => {
patchNotificationCheck(notificationId);

goToRunnerMyPage();
checkIsAllRead();
};

const handleDeleteNotification = (e: React.MouseEvent, notificationId: number) => {
e.stopPropagation();

deleteNotification(notificationId);
checkIsAllRead();
};

return (
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/layout/MyMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ const MyMenu = () => {
const [isAllRead, setIsAllRead] = useState<boolean>(true);

const { data: profile } = useHeaderProfile();

const { data: notificationList } = useNotification();

useEffect(() => {
const isRead = notificationList.data.filter((notification) => {
checkIsAllRead();
}, [isAllRead]);

const checkIsAllRead = () => {
const isNotRead = notificationList.data.filter((notification) => {
return !notification.isRead;
});

if (isRead.length !== 0) {
if (isNotRead.length !== 0) {
setIsAllRead(false);
}
}, [isAllRead]);
};

const handleNotificationDropdown = () => {
setIsNotificationDropdownOpen(!isNotificationDropdownOpen);
Expand Down Expand Up @@ -61,7 +64,7 @@ const MyMenu = () => {
}
>
<Suspense>
<NotificationDropdown notificationList={notificationList.data} />
<NotificationDropdown checkIsAllRead={checkIsAllRead} notificationList={notificationList.data} />
</Suspense>
</Dropdown>
</S.NotificationContainer>
Expand Down

0 comments on commit 4cd8bbd

Please sign in to comment.