chore: formatting

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

View File

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

View File

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

View File

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