diff --git a/src/element/nostr-provider-dialog.tsx b/src/element/nostr-provider-dialog.tsx
index 5eaf703..deaa39b 100644
--- a/src/element/nostr-provider-dialog.tsx
+++ b/src/element/nostr-provider-dialog.tsx
@@ -37,6 +37,16 @@ export function NostrProviderDialog({ provider, ...others }: { provider: StreamP
}} />
}
+ function calcEstimate() {
+ if (!info?.rate || !info?.unit || !info?.balance || !info.balance) return;
+
+ const raw = Math.max(0, info.balance / info.rate);
+ if (info.unit === "min" && raw > 60) {
+ return `${(raw / 60).toFixed(0)} hour`
+ }
+ return `${raw.toFixed(0)} ${info.unit}`
+ }
+
const streamEvent = others.ev ?? info.publishedEvent ?? DummyEvent;
return <>
@@ -66,6 +76,7 @@ export function NostrProviderDialog({ provider, ...others }: { provider: StreamP
Topup
+ About {calcEstimate()} @ {info.rate} sats/{info.unit}
{streamEvent && {
provider.updateStreamInfo(ex);
diff --git a/src/providers/index.ts b/src/providers/index.ts
index 66b6b4c..b16823c 100644
--- a/src/providers/index.ts
+++ b/src/providers/index.ts
@@ -48,6 +48,8 @@ export interface StreamProviderInfo {
ingressKey?: string
balance?: number
publishedEvent?: NostrEvent
+ rate?: number
+ unit?: string
}
export class ProviderStore extends ExternalStore> {
diff --git a/src/providers/nip103.ts b/src/providers/nip103.ts
index 3e672d3..6d6b598 100644
--- a/src/providers/nip103.ts
+++ b/src/providers/nip103.ts
@@ -29,7 +29,9 @@ export class Nip103StreamProvider implements StreamProvider {
ingressUrl: rsp.url,
ingressKey: rsp.key,
balance: rsp.quota.remaining,
- publishedEvent: rsp.event
+ publishedEvent: rsp.event,
+ rate: rsp.quota.rate,
+ unit: rsp.quota.unit
} as StreamProviderInfo
}
@@ -45,8 +47,9 @@ export class Nip103StreamProvider implements StreamProvider {
const summary = findTag(ev, "summary");
const image = findTag(ev, "image");
const tags = ev?.tags.filter(a => a[0] === "t").map(a => a[1]);
+ const contentWarning = findTag(ev, "content-warning");
await this.#getJson("PATCH", "event", {
- title, summary, image, tags
+ title, summary, image, tags, content_warning: contentWarning
});
}