fix: don't crash when no follows
This commit is contained in:
parent
508abaad1f
commit
c708870e04
@ -53,4 +53,4 @@
|
||||
|
||||
.new-stream .tos-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
@ -88,26 +88,41 @@ export function NostrProviderDialog({
|
||||
function tosInput() {
|
||||
if (!info) return;
|
||||
|
||||
return <>
|
||||
<div>
|
||||
<div className="flex g12">
|
||||
<input type="checkbox" checked={tos} onChange={e => setTos(e.target.checked)} />
|
||||
<p>
|
||||
I have read and agree with {info.name}'s <span className="tos-link" onClick={() => window.open(info.tosLink, "popup", "width=400,height=800")}>terms and conditions</span>.
|
||||
</p>
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<div className="flex g12">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={tos}
|
||||
onChange={(e) => setTos(e.target.checked)}
|
||||
/>
|
||||
<p>
|
||||
I have read and agree with {info.name}'s{" "}
|
||||
<span
|
||||
className="tos-link"
|
||||
onClick={() =>
|
||||
window.open(info.tosLink, "popup", "width=400,height=800")
|
||||
}
|
||||
>
|
||||
terms and conditions
|
||||
</span>
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<AsyncButton
|
||||
type="button"
|
||||
className="btn btn-primary wide"
|
||||
disabled={!tos}
|
||||
onClick={acceptTos}
|
||||
>
|
||||
Continue
|
||||
</AsyncButton>
|
||||
</div>
|
||||
</>
|
||||
<div>
|
||||
<AsyncButton
|
||||
type="button"
|
||||
className="btn btn-primary wide"
|
||||
disabled={!tos}
|
||||
onClick={acceptTos}
|
||||
>
|
||||
Continue
|
||||
</AsyncButton>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@ -167,26 +182,33 @@ export function NostrProviderDialog({
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{info.tosAccepted === false ? tosInput() :
|
||||
{info.tosAccepted === false ? (
|
||||
tosInput()
|
||||
) : (
|
||||
<StreamEditor
|
||||
onFinish={(ex) => {
|
||||
provider.updateStreamInfo(ex);
|
||||
others.onFinish?.(ex);
|
||||
}}
|
||||
ev={{
|
||||
tags: [
|
||||
["title", info.streamInfo?.title ?? ""],
|
||||
["summary", info.streamInfo?.summary ?? ""],
|
||||
["image", info.streamInfo?.image ?? ""],
|
||||
...(info.streamInfo?.content_warning ? [["content-warning", info.streamInfo?.content_warning]] : []),
|
||||
...(info.streamInfo?.tags?.map(a => ["t", a]) ?? [])
|
||||
]
|
||||
} as NostrEvent}
|
||||
ev={
|
||||
{
|
||||
tags: [
|
||||
["title", info.streamInfo?.title ?? ""],
|
||||
["summary", info.streamInfo?.summary ?? ""],
|
||||
["image", info.streamInfo?.image ?? ""],
|
||||
...(info.streamInfo?.content_warning
|
||||
? [["content-warning", info.streamInfo?.content_warning]]
|
||||
: []),
|
||||
...(info.streamInfo?.tags?.map((a) => ["t", a]) ?? []),
|
||||
],
|
||||
} as NostrEvent
|
||||
}
|
||||
options={{
|
||||
canSetStream: false,
|
||||
canSetStatus: false,
|
||||
}}
|
||||
/>}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -12,13 +12,14 @@ export function RootPage() {
|
||||
|
||||
const { live, planned, ended } = useStreamsFeed();
|
||||
const mutedHosts = new Set(getTagValues(login?.muted.tags ?? [], "p"));
|
||||
const tags = login?.follows.tags ?? [];
|
||||
const followsHost = useCallback(
|
||||
(ev: NostrEvent) => {
|
||||
return login?.follows.tags.find((t) => t.at(1) === getHost(ev));
|
||||
return tags.find((t) => t.at(1) === getHost(ev));
|
||||
},
|
||||
[login?.follows]
|
||||
[tags]
|
||||
);
|
||||
const hashtags = getTagValues(login?.follows.tags ?? [], "t");
|
||||
const hashtags = getTagValues(tags, "t");
|
||||
const following = live.filter(followsHost);
|
||||
const liveNow = live.filter((e) => !following.includes(e));
|
||||
const hasFollowingLive = following.length > 0;
|
||||
|
@ -53,7 +53,7 @@ export interface StreamProviderInfo {
|
||||
balance?: number;
|
||||
endpoints: Array<StreamProviderEndpoint>;
|
||||
tosAccepted?: boolean;
|
||||
tosLink?: string
|
||||
tosLink?: string;
|
||||
}
|
||||
|
||||
export interface StreamProviderEndpoint {
|
||||
@ -66,11 +66,11 @@ export interface StreamProviderEndpoint {
|
||||
}
|
||||
|
||||
export interface StreamProviderStreamInfo {
|
||||
title: string
|
||||
summary: string
|
||||
image: string
|
||||
tags: Array<string>
|
||||
content_warning: string
|
||||
title: string;
|
||||
summary: string;
|
||||
image: string;
|
||||
tags: Array<string>;
|
||||
content_warning: string;
|
||||
}
|
||||
|
||||
export class ProviderStore extends ExternalStore<Array<StreamProvider>> {
|
||||
|
@ -51,7 +51,7 @@ export class OwncastProvider implements StreamProvider {
|
||||
acceptTos(): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
|
||||
async #getJson<T>(
|
||||
method: "GET" | "POST",
|
||||
path: string,
|
||||
|
Loading…
Reference in New Issue
Block a user