import { useMemo } from 'react' import classNames from 'classnames' import { getURLsFromString } from '~/utils/url' import { NotificationPayload } from '~/utils/transactions' import ChronologicalScrollableFeed from '~/components/ChronologicalScrollableFeed' export default function Notifications(props: { notifications: NotificationPayload[] className?: string style?: React.CSSProperties isCompleted: boolean isFocused?: boolean }) { return (
{props.notifications.length === 0 ? (

No notifications sent yet.{' '} Use io.notify() in your action to send notifications.

) : ( )} {props.isCompleted &&

✔ Transaction completed

}

Notifications are not delivered in development, but they appear here to preview behavior for live actions.

) } function NotificationsLines({ notifications, }: { notifications: NotificationPayload[] }) { const lines = useMemo(() => { const lines: React.ReactElement[] = [] for (let i = 0; i < notifications.length; i++) { let message = notifications[i].message let title = notifications[i].title message = message.replace(//, '>') title = title && title.replace(//, '>') let line = title ? `${title}: ${message}` : message const urlMatches = getURLsFromString(line) if (urlMatches?.length) { for (let i = 0; i < urlMatches.length; i++) { const url = urlMatches[i] line = line.replace( url, `${url}` ) } } lines.push(

) } return lines }, [notifications]) return <>{lines.map(line => line)} }