Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide mark all as read button with no uread notifications #25348

Merged
merged 7 commits into from
Jun 18, 2024
1 change: 1 addition & 0 deletions ui/pages/notifications/notifications-list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('NotificationsList', () => {
notifications={[]}
isLoading={false}
isError={false}
notificationsCount={0}
/>
</MetamaskNotificationsProvider>
</Router>
Expand Down
3 changes: 2 additions & 1 deletion ui/pages/notifications/notifications-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type NotificationsListProps = {
notifications: NotificationType[];
isLoading: boolean;
isError: boolean;
notificationsCount: number;
};

function LoadingContent() {
Expand Down Expand Up @@ -120,7 +121,7 @@ export function NotificationsList(props: NotificationsListProps) {
<NotificationsListStates {...props} />

{/* Read All Button */}
{props.notifications.length > 0 ? (
{props.notifications.length > 0 && props.notificationsCount > 0 ? (
<NotificationsListReadAllButton notifications={props.notifications} />
) : null}
</Box>
Expand Down
3 changes: 3 additions & 0 deletions ui/pages/notifications/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { NotificationsPage } from '../../components/multichain';
import { Content, Header } from '../../components/multichain/pages/page';
import { useMetamaskNotificationsContext } from '../../contexts/metamask-notifications/metamask-notifications';
import { useCounter } from '../../hooks/metamask-notifications/useCounter';
import { getNotifications, getNotifySnaps } from '../../selectors';
import {
selectIsFeatureAnnouncementsEnabled,
Expand Down Expand Up @@ -165,6 +166,7 @@ export default function Notifications() {

const [activeTab, setActiveTab] = useState<TAB_KEYS>(TAB_KEYS.ALL);
const combinedNotifications = useCombinedNotifications();
const { notificationsCount } = useCounter();
const filteredNotifications = useMemo(
() => filterNotifications(activeTab, combinedNotifications),
[activeTab, combinedNotifications],
Expand Down Expand Up @@ -248,6 +250,7 @@ export default function Notifications() {
notifications={filteredNotifications}
isLoading={isLoading}
isError={Boolean(error)}
notificationsCount={notificationsCount}
/>
</Content>
</NotificationsPage>
Expand Down