Skip to content

Commit

Permalink
fix(protocol-designer): release notes banner dismisses upon clicking x (
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader authored Jan 7, 2025
1 parent 7e6f17f commit b28ef1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion protocol-designer/src/organisms/AnnouncementModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const AnnouncementModal = (
)

const handleClick = (): void => {
if (onClose != null) onClose()
if (onClose != null) {
onClose()
}
setLocalStorageItem(localStorageAnnouncementKey, announcementKey)
setShowAnnouncementModal(false)
}
Expand Down
19 changes: 15 additions & 4 deletions protocol-designer/src/pages/Landing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import { toggleNewProtocolModal } from '../../navigation/actions'
import { useKitchen } from '../../organisms/Kitchen/hooks'
import { getHasOptedIn } from '../../analytics/selectors'
import { useAnnouncements } from '../../organisms/AnnouncementModal/announcements'
import { getLocalStorageItem, localStorageAnnouncementKey } from '../../persist'
import {
getLocalStorageItem,
localStorageAnnouncementKey,
setLocalStorageItem,
} from '../../persist'
import welcomeImage from '../../assets/images/welcome_page.png'

import type { ChangeEvent, ComponentProps } from 'react'
Expand All @@ -39,7 +43,7 @@ export function Landing(): JSX.Element {
const [showAnnouncementModal, setShowAnnouncementModal] = useState<boolean>(
false
)
const { hasOptedIn } = useSelector(getHasOptedIn)
const { hasOptedIn, appVersion } = useSelector(getHasOptedIn)
const { bakeToast, eatToast } = useKitchen()
const announcements = useAnnouncements()
const lastAnnouncement = announcements[announcements.length - 1]
Expand All @@ -52,14 +56,21 @@ export function Landing(): JSX.Element {
hasOptedIn != null

useEffect(() => {
if (userHasNotSeenAnnouncement) {
if (
userHasNotSeenAnnouncement &&
appVersion != null &&
hasOptedIn != null
) {
const toastId = bakeToast(
t('learn_more', { version: process.env.OT_PD_VERSION }) as string,
INFO_TOAST,
{
heading: t('updated_protocol_designer'),
closeButton: true,
linkText: t('view_release_notes'),
onClose: () => {
setLocalStorageItem(localStorageAnnouncementKey, announcementKey)
},
onLinkClick: () => {
eatToast(toastId)
setShowAnnouncementModal(true)
Expand All @@ -69,7 +80,7 @@ export function Landing(): JSX.Element {
}
)
}
}, [userHasNotSeenAnnouncement])
}, [userHasNotSeenAnnouncement, appVersion, hasOptedIn])

useEffect(() => {
if (metadata?.created != null) {
Expand Down

0 comments on commit b28ef1e

Please sign in to comment.