Skip to content

Commit

Permalink
solving fetching error
Browse files Browse the repository at this point in the history
  • Loading branch information
Bardala committed Nov 17, 2023
1 parent 0409b8a commit 2145606
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
36 changes: 18 additions & 18 deletions frontend/src/components/NotificationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ export const NotificationMenu = () => {
const notificationRef = useRef<HTMLDivElement>(null);
useClickOutside(notificationRef, () => setShowNotification(false));

useEffect(() => {
if (missedMsgs?.length! > 0) {
const lastMsg = missedMsgs![0];
if (Notification.permission === 'granted') {
new Notification('New message', {
body: `You have ${lastMsg?.unread_count} new messages in ${lastMsg.spaceName}`,
});
} else if (Notification.permission !== 'denied') {
Notification.requestPermission().then(permission => {
if (permission === 'granted') {
new Notification('New message', {
body: `You have ${lastMsg?.unread_count} new messages in ${lastMsg.spaceName}`,
});
}
});
}
}
}, [missedMsgs]);
// useEffect(() => {
// if (missedMsgs?.length! > 0) {
// const lastMsg = missedMsgs![0];
// if (Notification.permission === 'granted') {
// new Notification('New message', {
// body: `You have ${lastMsg?.unread_count} new messages in ${lastMsg.spaceName}`,
// });
// } else if (Notification.permission !== 'denied') {
// Notification.requestPermission().then(permission => {
// if (permission === 'granted') {
// new Notification('New message', {
// body: `You have ${lastMsg?.unread_count} new messages in ${lastMsg.spaceName}`,
// });
// }
// });
// }
// }
// }, [missedMsgs]);

return (
<div ref={notificationRef}>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { FormEvent, useState } from 'react';
import { Link, useParams } from 'react-router-dom';

import { BlogList } from '../components/BlogList';
import { NotificationMsgsNumber } from '../components/NotificationNumberMsgs';
import { UserInfoCard } from '../components/UserInfoCard';
import { useAuthContext } from '../context/AuthContext';
import { useProfileData } from '../hooks/useProfileData';
Expand Down Expand Up @@ -62,7 +61,9 @@ export const UserProfile = () => {
space.id !== '1' && (
<div className="space" key={space.id}>
<Link to={`/space/${space.id}`} className="space-link">
<p>{space.name}</p> <NotificationMsgsNumber spaceId={space.id} />
<p>{space.name}</p>
{/* <NotificationMsgsNumber spaceId={space.id}/> */}
{/* //! this cause errors, don't use this component in Map because it calls api in it*/}
</Link>
</div>
)
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/styles/blogList.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,8 @@ time {
margin-left: 4px;
margin-right: 4px;
}

.space-page .blog-list {
grid-template-columns: 1fr;
}
}

0 comments on commit 2145606

Please sign in to comment.