chore: formatting

This commit is contained in:
2023-12-07 22:50:55 +00:00
parent 31b8549632
commit dd4c2bae2b
3 changed files with 89 additions and 57 deletions

View File

@ -15,7 +15,12 @@ export function NostrProviderDialog({
showEditor, showEditor,
showForwards, showForwards,
...others ...others
}: { provider: NostrStreamProvider; showEndpoints: boolean; showEditor: boolean, showForwards: boolean } & StreamEditorProps) { }: {
provider: NostrStreamProvider;
showEndpoints: boolean;
showEditor: boolean;
showForwards: boolean;
} & StreamEditorProps) {
const system = useContext(SnortContext); const system = useContext(SnortContext);
const [topup, setTopup] = useState(false); const [topup, setTopup] = useState(false);
const [info, setInfo] = useState<StreamProviderInfo>(); const [info, setInfo] = useState<StreamProviderInfo>();
@ -134,7 +139,9 @@ export function NostrProviderDialog({
</p> </p>
<div className="flex gap-2"> <div className="flex gap-2">
{sortEndpoints(info.endpoints).map(a => ( {sortEndpoints(info.endpoints).map(a => (
<span className={`pill bg-gray-1${ep?.name === a.name ? " active" : ""}`} onClick={() => setEndpoint(a)}> <span
className={`pill bg-gray-1${ep?.name === a.name ? " active" : ""}`}
onClick={() => setEndpoint(a)}>
{a.name} {a.name}
</span> </span>
))} ))}
@ -202,51 +209,59 @@ export function NostrProviderDialog({
return tosInput(); return tosInput();
} }
return <StreamEditor return (
onFinish={ex => { <StreamEditor
provider.updateStreamInfo(system, ex); onFinish={ex => {
others.onFinish?.(ex); provider.updateStreamInfo(system, ex);
}} others.onFinish?.(ex);
ev={ }}
{ ev={
tags: [ {
["title", info.streamInfo?.title ?? ""], tags: [
["summary", info.streamInfo?.summary ?? ""], ["title", info.streamInfo?.title ?? ""],
["image", info.streamInfo?.image ?? ""], ["summary", info.streamInfo?.summary ?? ""],
...(info.streamInfo?.goal ? [["goal", info.streamInfo.goal]] : []), ["image", info.streamInfo?.image ?? ""],
...(info.streamInfo?.content_warning ? [["content-warning", info.streamInfo?.content_warning]] : []), ...(info.streamInfo?.goal ? [["goal", info.streamInfo.goal]] : []),
...(info.streamInfo?.tags?.map(a => ["t", a]) ?? []), ...(info.streamInfo?.content_warning ? [["content-warning", info.streamInfo?.content_warning]] : []),
], ...(info.streamInfo?.tags?.map(a => ["t", a]) ?? []),
} as NostrEvent ],
} } as NostrEvent
options={{ }
canSetStream: false, options={{
canSetStatus: false, canSetStream: false,
}} canSetStatus: false,
/>; }}
/>
);
} }
function forwardInputs() { function forwardInputs() {
if (!info || !showForwards) return; if (!info || !showForwards) return;
return <div className="flex flex-col gap-4"> return (
<h3> <div className="flex flex-col gap-4">
<FormattedMessage defaultMessage="Stream Forwarding" id="W7DNWx" /> <h3>
</h3> <FormattedMessage defaultMessage="Stream Forwarding" id="W7DNWx" />
</h3>
<div className="grid grid-cols-3 gap-2"> <div className="grid grid-cols-3 gap-2">
{info.forwards?.map(a => <> {info.forwards?.map(a => (
<div className="paper">{a.name}</div> <>
<AsyncButton className="btn btn-primary" onClick={async () => { <div className="paper">{a.name}</div>
await provider.removeForward(a.id); <AsyncButton
}}> className="btn btn-primary"
<FormattedMessage defaultMessage="Remove" id="G/yZLu" /> onClick={async () => {
</AsyncButton> await provider.removeForward(a.id);
<div></div> }}>
</>)} <FormattedMessage defaultMessage="Remove" id="G/yZLu" />
<AddForwardInputs provider={provider} onAdd={() => { }} /> </AsyncButton>
<div></div>
</>
))}
<AddForwardInputs provider={provider} onAdd={() => {}} />
</div>
</div> </div>
</div> );
} }
return ( return (
@ -258,7 +273,13 @@ export function NostrProviderDialog({
); );
} }
function AddForwardInputs({ provider, onAdd }: { provider: NostrStreamProvider, onAdd: (name: string, target: string) => void }) { function AddForwardInputs({
provider,
onAdd,
}: {
provider: NostrStreamProvider;
onAdd: (name: string, target: string) => void;
}) {
const [name, setName] = useState(""); const [name, setName] = useState("");
const [target, setTarget] = useState(""); const [target, setTarget] = useState("");
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
@ -270,19 +291,22 @@ function AddForwardInputs({ provider, onAdd }: { provider: NostrStreamProvider,
onAdd(name, target); onAdd(name, target);
} }
return <> return (
<div className="paper"> <>
<input type="text" <div className="paper">
placeholder={formatMessage({ defaultMessage: "Human readable name", id: 'QuXHCg' })} <input
value={name} onChange={e => setName(e.target.value)} /> type="text"
</div> placeholder={formatMessage({ defaultMessage: "Human readable name", id: "QuXHCg" })}
<div className="paper"> value={name}
<input type="text" onChange={e => setName(e.target.value)}
placeholder="rtmp://" />
value={target} onChange={e => setTarget(e.target.value)} /> </div>
</div> <div className="paper">
<AsyncButton className="btn btn-primary" onClick={doAdd}> <input type="text" placeholder="rtmp://" value={target} onChange={e => setTarget(e.target.value)} />
<FormattedMessage defaultMessage="Add" id="2/2yg+" /> </div>
</AsyncButton> <AsyncButton className="btn btn-primary" onClick={doAdd}>
</> <FormattedMessage defaultMessage="Add" id="2/2yg+" />
</AsyncButton>
</>
);
} }

View File

@ -239,6 +239,9 @@
"Qe1MJu": { "Qe1MJu": {
"defaultMessage": "{name} with {amount}" "defaultMessage": "{name} with {amount}"
}, },
"QuXHCg": {
"defaultMessage": "Human readable name"
},
"RJ2VxG": { "RJ2VxG": {
"defaultMessage": "A new version has been detected" "defaultMessage": "A new version has been detected"
}, },
@ -275,6 +278,9 @@
"VA/Z1S": { "VA/Z1S": {
"defaultMessage": "Hide" "defaultMessage": "Hide"
}, },
"W7DNWx": {
"defaultMessage": "Stream Forwarding"
},
"W9355R": { "W9355R": {
"defaultMessage": "Unmute" "defaultMessage": "Unmute"
}, },

View File

@ -79,6 +79,7 @@
"QRRCp0": "Stream URL", "QRRCp0": "Stream URL",
"QceMQZ": "Goal: {amount}", "QceMQZ": "Goal: {amount}",
"Qe1MJu": "{name} with {amount}", "Qe1MJu": "{name} with {amount}",
"QuXHCg": "Human readable name",
"RJ2VxG": "A new version has been detected", "RJ2VxG": "A new version has been detected",
"RJOmzk": "I have read and agree with {provider}''s {terms}.", "RJOmzk": "I have read and agree with {provider}''s {terms}.",
"RS6smY": "Raid Message", "RS6smY": "Raid Message",
@ -91,6 +92,7 @@
"UJBFYK": "Add Card", "UJBFYK": "Add Card",
"UfSot5": "Past Streams", "UfSot5": "Past Streams",
"VA/Z1S": "Hide", "VA/Z1S": "Hide",
"W7DNWx": "Stream Forwarding",
"W9355R": "Unmute", "W9355R": "Unmute",
"X2PZ7D": "Create Goal", "X2PZ7D": "Create Goal",
"XgWvGA": "Reactions", "XgWvGA": "Reactions",