import Container from "@mui/material/Container"; import {CardContent, Link, Stack} from "@mui/material"; import Card from "@mui/material/Card"; import Typography from "@mui/material/Typography"; import * as React from "react"; import {formatMessage, formatTitle, topicShortUrl, unmatchedTags} from "../app/utils"; import IconButton from "@mui/material/IconButton"; import CloseIcon from '@mui/icons-material/Close'; import {Paragraph, VerticallyCenteredContainer} from "./styles"; import {useLiveQuery} from "dexie-react-hooks"; import db from "../app/db"; const Notifications = (props) => { const subscription = props.subscription; const notifications = useLiveQuery(() => { return db.notifications .where({ subscriptionId: subscription.id }) .toArray(); }, [subscription]); if (!notifications || notifications.length === 0) { return ; } const sortedNotifications = Array.from(notifications) .sort((a, b) => a.time < b.time ? 1 : -1); return ( {sortedNotifications.map(notification => )} ); } const NotificationItem = (props) => { const subscriptionId = props.subscriptionId; const notification = props.notification; const date = new Intl.DateTimeFormat('default', {dateStyle: 'short', timeStyle: 'short'}) .format(new Date(notification.time * 1000)); const otherTags = unmatchedTags(notification.tags); const tags = (otherTags.length > 0) ? otherTags.join(', ') : null; const handleDelete = async () => { console.log(`[Notifications] Deleting notification ${notification.id} from ${subscriptionId}`); await db.notifications.delete(notification.id); // FIXME } return ( {date} {[1,2,4,5].includes(notification.priority) && {`Priority} {notification.title && {formatTitle(notification)}} {formatMessage(notification)} {tags && Tags: {tags}} ); } const NothingHereYet = (props) => { const shortUrl = topicShortUrl(props.subscription.baseUrl, props.subscription.topic); return ( No notifications
You haven't received any notifications for this topic yet.
To send notifications to this topic, simply PUT or POST to the topic URL. Example:
$ curl -d "Hi" {shortUrl}
For more detailed instructions, check out the website or {" "}documentation.
); }; export default Notifications;