Skip to content

Commit

Permalink
fix publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Sep 25, 2024
1 parent 327a4eb commit b96f496
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions src/views/tools/event-publisher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -100,33 +99,17 @@ function EventPublisherPage({ initDraft }: { initDraft?: LooseEventTemplate }) {
if (!finalized || !(finalized as NostrEvent).sig) return;
try {
setLoading(true);
const valid = verifyEvent(draft as NostrEvent);
if (!valid) throw new Error("Invalid event");
if (customRelayURL) {
await publish("Custom Event", finalized, [customRelayURL], true, true);
} else {
await publish("Custom Event", finalized);
}
setFinalized(undefined);
} catch (e) {
if (e instanceof Error) toast({ description: e.message, status: "error" });
}
setLoading(false);
};
let event: NostrEvent;

const yolo = async () => {
try {
if (!account) return;

setLoading(true);
const event = await requestSignature(processEvent(draft, variables, account));
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", event, [customRelayURL], true, true);
await publish("Custom Event", finalized, [customRelayURL], true, true);
} else {
await publish("Custom Event", event);
await publish("Custom Event", finalized);
}
setFinalized(undefined);
} catch (e) {
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit b96f496

Please sign in to comment.