Fix selected goal

This commit is contained in:
Kieran 2023-09-29 11:03:33 +01:00
parent 11ead3e8bd
commit d9bcea518b
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
3 changed files with 9 additions and 7 deletions

View File

@ -190,6 +190,7 @@ export function NostrProviderDialog({ provider, ...others }: { provider: StreamP
["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]) ?? []),
],

View File

@ -36,11 +36,11 @@ function GoalSelector({ goal, pubkey, onGoalSelect }: GoalSelectorProps) {
const goals = useGoals(pubkey, true);
const { formatMessage } = useIntl();
return (
<select defaultValue={goal} onChange={ev => onGoalSelect(ev.target.value)}>
<select onChange={ev => onGoalSelect(ev.target.value)}>
<option value="">{formatMessage({ defaultMessage: "Select a goal..." })}</option>
{goals?.map(goal => (
<option key={goal.id} value={goal.id}>
{goal.content}
{goals?.map(x => (
<option key={x.id} value={x.id} selected={goal === x.id}>
{x.content}
</option>
))}
</select>
@ -57,7 +57,7 @@ export function StreamEditor({ ev, onFinish, options }: StreamEditorProps) {
const [tags, setTags] = useState<string[]>([]);
const [contentWarning, setContentWarning] = useState(false);
const [isValid, setIsValid] = useState(false);
const [goal, setGoal] = useState<string | undefined>();
const [goal, setGoal] = useState<string>();
const login = useLogin();
const { formatMessage } = useIntl();

View File

@ -69,8 +69,9 @@ export interface StreamProviderStreamInfo {
title: string;
summary: string;
image: string;
tags: Array<string>;
content_warning: string;
tags?: Array<string>;
content_warning?: string;
goal?: string;
}
export const DefaultProvider = new Nip103StreamProvider("zap.stream", "https://api.zap.stream/api/nostr/");