From 4f5c93be96d603fc07858dd1b56d6206a9587a08 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Mon, 10 Oct 2022 15:01:18 -0600 Subject: [PATCH] Badge notifications ui changes --- web/components/badge-display.tsx | 12 ++++++------ web/components/user-page.tsx | 6 +++--- web/pages/notifications.tsx | 15 ++++++++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/web/components/badge-display.tsx b/web/components/badge-display.tsx index 983956cd..df101c7d 100644 --- a/web/components/badge-display.tsx +++ b/web/components/badge-display.tsx @@ -1,10 +1,10 @@ import { User } from 'common/user' -import { NextRouter } from 'next/router' import { useEffect, useState } from 'react' import { getBadgesByRarity } from 'common/badge' import { Row } from 'web/components/layout/row' import clsx from 'clsx' import { BadgesModal } from 'web/components/profile/badges-modal' +import { ParsedUrlQuery } from 'querystring' export const goldClassName = 'text-amber-400' export const silverClassName = 'text-gray-500' @@ -12,16 +12,16 @@ export const bronzeClassName = 'text-amber-900' export function BadgeDisplay(props: { user: User | undefined | null - router?: NextRouter + query: ParsedUrlQuery }) { - const { user, router } = props + const { user, query } = props const [showBadgesModal, setShowBadgesModal] = useState(false) useEffect(() => { - if (!router) return - const showBadgesModal = router.query['show'] === 'badges' + const showBadgesModal = query['show'] == 'badges' setShowBadgesModal(showBadgesModal) - }, [router]) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) // get number of badges of each rarity type const badgesByRarity = getBadgesByRarity(user) const badgesByRarityItems = Object.entries(badgesByRarity).map( diff --git a/web/components/user-page.tsx b/web/components/user-page.tsx index f0ad0569..3f2176dc 100644 --- a/web/components/user-page.tsx +++ b/web/components/user-page.tsx @@ -50,8 +50,8 @@ export function UserPage(props: { user: User }) { setShowConfetti(claimedMana) const query = { ...router.query } if (query.claimedMana || query.show) { - delete query['claimed-mana'] - delete query['show'] + const queriesToDelete = ['claimed-mana', 'show', 'badge'] + queriesToDelete.forEach((key) => delete query[key]) router.replace( { pathname: router.pathname, @@ -102,7 +102,7 @@ export function UserPage(props: { user: User }) { @{user.username} - + {isCurrentUser && ( diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index f7e4bc84..dd622a72 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -826,7 +826,8 @@ function NotificationFrame(props: { subtitle: string children: React.ReactNode isChildOfGroup?: boolean - showUserName?: boolean + hideUserName?: boolean + hideLinkToGroupOrQuestion?: boolean }) { const { notification, @@ -834,7 +835,8 @@ function NotificationFrame(props: { highlighted, subtitle, children, - showUserName, + hideUserName, + hideLinkToGroupOrQuestion, } = props const { sourceType, @@ -888,7 +890,7 @@ function NotificationFrame(props: { } >
- {showUserName && ( + {!hideUserName && ( ) : ( - + !hideLinkToGroupOrQuestion && ( + + ) )}
@@ -1034,7 +1038,8 @@ function BadgeNotification(props: { isChildOfGroup={isChildOfGroup} highlighted={highlighted} subtitle={subtitle} - showUserName={false} + hideUserName={true} + hideLinkToGroupOrQuestion={true} > {sourceText} 🎉