mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-17 21:31:43 +01:00
fix publishing
This commit is contained in:
parent
327a4eb842
commit
b96f496fb7
@ -38,7 +38,6 @@ import RequireCurrentAccount from "../../../providers/route/require-current-acco
|
||||
import VariableEditor from "./components/variable-editor";
|
||||
import EventTemplateEditor from "./components/event-template-editor";
|
||||
import useRouteStateValue from "../../../hooks/use-route-state-value";
|
||||
import { cloneEvent } from "../../../helpers/nostr/event";
|
||||
|
||||
function EventPublisherPage({ initDraft }: { initDraft?: LooseEventTemplate }) {
|
||||
const toast = useToast();
|
||||
@ -100,7 +99,12 @@ function EventPublisherPage({ initDraft }: { initDraft?: LooseEventTemplate }) {
|
||||
if (!finalized || !(finalized as NostrEvent).sig) return;
|
||||
try {
|
||||
setLoading(true);
|
||||
const valid = verifyEvent(draft as NostrEvent);
|
||||
let event: NostrEvent;
|
||||
|
||||
if ((finalized as NostrEvent).sig) event = finalized as NostrEvent;
|
||||
else event = await requestSignature(processEvent(finalized, variables, account));
|
||||
|
||||
const valid = verifyEvent(event);
|
||||
if (!valid) throw new Error("Invalid event");
|
||||
if (customRelayURL) {
|
||||
await publish("Custom Event", finalized, [customRelayURL], true, true);
|
||||
@ -114,27 +118,6 @@ function EventPublisherPage({ initDraft }: { initDraft?: LooseEventTemplate }) {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const yolo = async () => {
|
||||
try {
|
||||
if (!account) return;
|
||||
|
||||
setLoading(true);
|
||||
const event = await requestSignature(processEvent(draft, variables, account));
|
||||
|
||||
const valid = verifyEvent(event);
|
||||
if (!valid) throw new Error("Invalid event");
|
||||
if (customRelayURL) {
|
||||
await publish("Custom Event", event, [customRelayURL], true, true);
|
||||
} else {
|
||||
await publish("Custom Event", event);
|
||||
}
|
||||
setFinalized(undefined);
|
||||
} catch (e) {
|
||||
if (e instanceof Error) toast({ description: e.message, status: "error" });
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const selectTemplate = (name: string) => {
|
||||
const template = TEMPLATES.find((t) => t.name === name);
|
||||
if (template) {
|
||||
@ -264,9 +247,6 @@ function EventPublisherPage({ initDraft }: { initDraft?: LooseEventTemplate }) {
|
||||
<Button mr={2} onClick={() => setFinalized(undefined)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button colorScheme="primary" onClick={yolo} isLoading={loading}>
|
||||
Yolo
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
Loading…
x
Reference in New Issue
Block a user