diff --git a/public/icons.svg b/public/icons.svg index e1c4d3d..7e8b218 100644 --- a/public/icons.svg +++ b/public/icons.svg @@ -92,5 +92,8 @@ + + + diff --git a/src/hooks/status.ts b/src/hooks/status.ts new file mode 100644 index 0000000..2ebfc0f --- /dev/null +++ b/src/hooks/status.ts @@ -0,0 +1,22 @@ +import { useMemo } from "react"; + +import { EventKind, ReplaceableNoteStore, RequestBuilder } from "@snort/system"; +import { useRequestBuilder } from "@snort/system-react"; + +type StatusTag = "general" | "music"; + +export function useStatus(tag: StatusTag, author?: string, leaveOpen = true) { + const sub = useMemo(() => { + if (!author) return null; + const b = new RequestBuilder(`status:${tag}:${author.slice(0, 8)}`); + b.withOptions({ leaveOpen }); + b.withFilter() + .kinds([30315 as EventKind]) + .tag("d", [tag]) + .authors([author]); + return b; + }, [author]); + + const { data } = useRequestBuilder(ReplaceableNoteStore, sub); + return data; +} diff --git a/src/pages/alerts.css b/src/pages/alerts.css index d283147..e89f532 100644 --- a/src/pages/alerts.css +++ b/src/pages/alerts.css @@ -110,3 +110,21 @@ width: 24px; height: 24px; } + +.music { + display: flex; + flex-direction: column; + align-items: center; + padding: 16px; + gap: 4px; +} + +.music .cover { + object-fit: cover; + width: 120px; + height: 120px; +} + +.music .track { + margin: 0; +} diff --git a/src/pages/alerts.tsx b/src/pages/alerts.tsx index 567943f..5205d7b 100644 --- a/src/pages/alerts.tsx +++ b/src/pages/alerts.tsx @@ -5,6 +5,7 @@ import { useParams } from "react-router-dom"; import { ZapAlerts } from "./widgets/zaps"; import { Views } from "./widgets/views"; import { TopZappersWidget } from "./widgets/top-zappers"; +import { Music } from "./widgets/music"; export function AlertsPage() { const params = useParams(); @@ -24,6 +25,9 @@ export function AlertsPage() { case "top-zappers": { return ; } + case "music": { + return ; + } } return null; } diff --git a/src/pages/layout.tsx b/src/pages/layout.tsx index 962f0b0..4001b9a 100644 --- a/src/pages/layout.tsx +++ b/src/pages/layout.tsx @@ -78,7 +78,11 @@ export function LayoutPage() { navigate("/settings")}> - Settings + + + navigate("/widgets")}> + + Login.logout()}> diff --git a/src/pages/widgets.tsx b/src/pages/widgets.tsx index 2c4dd32..dfe6baa 100644 --- a/src/pages/widgets.tsx +++ b/src/pages/widgets.tsx @@ -12,6 +12,7 @@ import { eventToLink, hexToBech32 } from "utils"; import { ZapAlertItem } from "./widgets/zaps"; import { TopZappersWidget } from "./widgets/top-zappers"; import { Views } from "./widgets/views"; +import { Music } from "./widgets/music"; import groupBy from "lodash/groupBy"; interface ZapAlertConfigurationProps { @@ -195,6 +196,13 @@ export function WidgetsPage() { {currentLink && } +
+

+ +

+ + {currentLink && } +
); } diff --git a/src/pages/widgets/music.tsx b/src/pages/widgets/music.tsx new file mode 100644 index 0000000..11f6ca1 --- /dev/null +++ b/src/pages/widgets/music.tsx @@ -0,0 +1,22 @@ +import { NostrLink } from "@snort/system"; +import { unixNow } from "@snort/shared"; +import { useCurrentStreamFeed } from "hooks/current-stream-feed"; +import { useStatus } from "hooks/status"; +import { getHost, findTag } from "utils"; + +export function Music({ link }: { link: NostrLink }) { + const currentEvent = useCurrentStreamFeed(link, true); + const host = getHost(currentEvent); + const nowPlaying = useStatus("music", host, true); + const cover = nowPlaying && findTag(nowPlaying, "cover"); + const expiry = nowPlaying && findTag(nowPlaying, "expiration"); + const isExpired = expiry && Number(expiry) > unixNow(); + return ( + !isExpired && ( +
+ {cover && {nowPlaying.content}} + {nowPlaying &&

🎵 {nowPlaying.content}

} +
+ ) + ); +} diff --git a/src/translations/ar_SA.json b/src/translations/ar_SA.json index e5d924d..067b125 100644 --- a/src/translations/ar_SA.json +++ b/src/translations/ar_SA.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Alert" } } - diff --git a/src/translations/bg_BG.json b/src/translations/bg_BG.json index 8dd0828..32cdf7d 100644 --- a/src/translations/bg_BG.json +++ b/src/translations/bg_BG.json @@ -418,4 +418,3 @@ "defaultMessage": "Зап Тревога" } } - diff --git a/src/translations/bn_BD.json b/src/translations/bn_BD.json index b991378..a437db1 100644 --- a/src/translations/bn_BD.json +++ b/src/translations/bn_BD.json @@ -418,4 +418,3 @@ "defaultMessage": "জ্যাপ অ্যালার্ট" } } - diff --git a/src/translations/da_DK.json b/src/translations/da_DK.json index 0966355..9b42556 100644 --- a/src/translations/da_DK.json +++ b/src/translations/da_DK.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Alert" } } - diff --git a/src/translations/de_DE.json b/src/translations/de_DE.json index 59f7a89..b8deb12 100644 --- a/src/translations/de_DE.json +++ b/src/translations/de_DE.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Alert" } } - diff --git a/src/translations/es_ES.json b/src/translations/es_ES.json index 501a682..a0ebbcd 100644 --- a/src/translations/es_ES.json +++ b/src/translations/es_ES.json @@ -418,4 +418,3 @@ "defaultMessage": "Alerta de Zap" } } - diff --git a/src/translations/fa_IR.json b/src/translations/fa_IR.json index 2567df4..fc0b695 100644 --- a/src/translations/fa_IR.json +++ b/src/translations/fa_IR.json @@ -418,4 +418,3 @@ "defaultMessage": "هشدار زپ" } } - diff --git a/src/translations/fi_FI.json b/src/translations/fi_FI.json index 042d774..5b0f580 100644 --- a/src/translations/fi_FI.json +++ b/src/translations/fi_FI.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap-hälytys" } } - diff --git a/src/translations/fr_FR.json b/src/translations/fr_FR.json index 06b6e1d..801d02c 100644 --- a/src/translations/fr_FR.json +++ b/src/translations/fr_FR.json @@ -418,4 +418,3 @@ "defaultMessage": "Alerte Zap" } } - diff --git a/src/translations/hu_HU.json b/src/translations/hu_HU.json index 7321e37..b6774a0 100644 --- a/src/translations/hu_HU.json +++ b/src/translations/hu_HU.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Riadó" } } - diff --git a/src/translations/it_IT.json b/src/translations/it_IT.json index f090cd9..555a10e 100644 --- a/src/translations/it_IT.json +++ b/src/translations/it_IT.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Alert" } } - diff --git a/src/translations/ja_JP.json b/src/translations/ja_JP.json index e9fc2f8..70dda94 100644 --- a/src/translations/ja_JP.json +++ b/src/translations/ja_JP.json @@ -418,4 +418,3 @@ "defaultMessage": "ザップアラート" } } - diff --git a/src/translations/nl_NL.json b/src/translations/nl_NL.json index 8d80233..be659e9 100644 --- a/src/translations/nl_NL.json +++ b/src/translations/nl_NL.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Alert" } } - diff --git a/src/translations/pt_BR.json b/src/translations/pt_BR.json index 13fce56..4fcc443 100644 --- a/src/translations/pt_BR.json +++ b/src/translations/pt_BR.json @@ -418,4 +418,3 @@ "defaultMessage": "Alerta Zap" } } - diff --git a/src/translations/ru_RU.json b/src/translations/ru_RU.json index 45c8a0c..f986c63 100644 --- a/src/translations/ru_RU.json +++ b/src/translations/ru_RU.json @@ -418,4 +418,3 @@ "defaultMessage": "Оповещение о запе" } } - diff --git a/src/translations/sv_SE.json b/src/translations/sv_SE.json index da9ab62..50f87a4 100644 --- a/src/translations/sv_SE.json +++ b/src/translations/sv_SE.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Alert" } } - diff --git a/src/translations/sw_KE.json b/src/translations/sw_KE.json index 5036802..ec0f619 100644 --- a/src/translations/sw_KE.json +++ b/src/translations/sw_KE.json @@ -418,4 +418,3 @@ "defaultMessage": "Tahadhari ya Zap" } } - diff --git a/src/translations/th_TH.json b/src/translations/th_TH.json index 556aacf..1455f7b 100644 --- a/src/translations/th_TH.json +++ b/src/translations/th_TH.json @@ -418,4 +418,3 @@ "defaultMessage": "Zap Alert" } } - diff --git a/src/translations/zh_CN.json b/src/translations/zh_CN.json index 99150bd..71c3f4e 100644 --- a/src/translations/zh_CN.json +++ b/src/translations/zh_CN.json @@ -418,4 +418,3 @@ "defaultMessage": "打闪提示" } } - diff --git a/src/translations/zh_TW.json b/src/translations/zh_TW.json index e82f18f..9f4950c 100644 --- a/src/translations/zh_TW.json +++ b/src/translations/zh_TW.json @@ -418,4 +418,3 @@ "defaultMessage": "打閃提示" } } -