diff --git a/components/adv-post-form.js b/components/adv-post-form.js
index 2d2707b7b..2d226fc13 100644
--- a/components/adv-post-form.js
+++ b/components/adv-post-form.js
@@ -88,9 +88,9 @@ export default function AdvPostForm () {
we use your NIP-05 relays if set
otherwise we default to these relays:
- {DEFAULT_CROSSPOSTING_RELAYS.map((relay, i) => (
- - {relay}
- ))}
+ {DEFAULT_CROSSPOSTING_RELAYS.map((relay, i) => (
+ - {relay}
+ ))}
@@ -98,7 +98,7 @@ export default function AdvPostForm () {
}
name='crosspost'
hint={crosspost to nostr}
- />
+ />
>
}
/>
diff --git a/components/discussion-form.js b/components/discussion-form.js
index 86fcf81cf..4d42f87e5 100644
--- a/components/discussion-form.js
+++ b/components/discussion-form.js
@@ -13,14 +13,13 @@ import { discussionSchema } from '../lib/validate'
import { SubSelectInitial } from './sub-select-form'
import CancelButton from './cancel-button'
import { useCallback } from 'react'
-import { crosspostDiscussion } from '../lib/nostr'
+import { crosspostDiscussion, DEFAULT_CROSSPOSTING_RELAYS } from '../lib/nostr'
import { normalizeForwards } from '../lib/form'
import { MAX_TITLE_LENGTH } from '../lib/constants'
-import {DEFAULT_CROSSPOSTING_RELAYS} from '../lib/nostr'
import { useMe } from './me'
import { useToast } from './toast'
-export function DiscussionForm({
+export function DiscussionForm ({
item, sub, editThreshold, titleLabel = 'title',
textLabel = 'text', buttonText = 'post',
handleSubmit, children
@@ -32,7 +31,7 @@ export function DiscussionForm({
// if Web Share Target API was used
const shareTitle = router.query.title
const Toast = useToast()
- const relays = [...DEFAULT_CROSSPOSTING_RELAYS, ...me?.nostrRelays || []];
+ const relays = [...DEFAULT_CROSSPOSTING_RELAYS, ...me?.nostrRelays || []]
const [upsertDiscussion] = useMutation(
gql`
@@ -47,51 +46,56 @@ export function DiscussionForm({
return new Promise((resolve) => {
const { removeToast } = Toast.danger(
<>
- Crossposting failed for {failedRelays.join(", ")}
-
- {" | "}
-
+ Crossposting failed for {failedRelays.join(', ')}
+
+ {' | '}
+
>,
() => resolve('skip') // will skip if user closes the toast
- );
- });
- };
-
+ )
+ })
+ }
+
const handleCrosspost = async (values, id) => {
- let failedRelays;
- let allSuccessful = false;
+ let failedRelays
+ let allSuccessful = false
do {
- let result = await crosspostDiscussion(values, id, failedRelays || relays);
+ const result = await crosspostDiscussion(values, id, failedRelays || relays)
result.successfulRelays.forEach(relay => {
- Toast.success(`Crossposting succeeded on relay ${relay}`);
- });
+ Toast.success(`Crossposting succeeded on relay ${relay}`)
+ })
- failedRelays = result.failedRelays.map(relayObj => relayObj.relay);
+ failedRelays = result.failedRelays.map(relayObj => relayObj.relay)
if (failedRelays.length > 0) {
- const userAction = await relayError(failedRelays);
+ const userAction = await relayError(failedRelays)
if (userAction === 'skip') {
- Toast.success("Crossposting skipped.");
- break;
+ Toast.success('Crossposting skipped.')
+ break
}
} else {
- allSuccessful = true;
+ allSuccessful = true
}
+ } while (failedRelays.length > 0)
- } while (failedRelays.length > 0);
-
- return { allSuccessful };
- };
+ return { allSuccessful }
+ }
const onSubmit = useCallback(
async ({ boost, crosspost, ...values }) => {
@@ -112,7 +116,7 @@ export function DiscussionForm({
const shouldCrosspost = me?.nostrCrossposting && crosspost
if (shouldCrosspost && data?.upsertDiscussion?.id) {
- const results = await handleCrosspost(values, data.upsertDiscussion.id);
+ const results = await handleCrosspost(values, data.upsertDiscussion.id)
if (results.allSuccessful) {
if (item) {
await router.push(`/items/${item.id}`)
diff --git a/components/toast.js b/components/toast.js
index 8a4b96afb..51c4fb58c 100644
--- a/components/toast.js
+++ b/components/toast.js
@@ -34,17 +34,17 @@ export const ToastProvider = ({ children }) => {
})
},
danger: (body, onCloseCallback) => {
- const id = toastId.current;
+ const id = toastId.current
dispatchToast({
id,
body,
variant: 'danger',
autohide: false,
- onCloseCallback,
+ onCloseCallback
})
return {
removeToast: () => removeToast(id)
- };
+ }
}
}), [dispatchToast])
@@ -74,8 +74,8 @@ export const ToastProvider = ({ children }) => {
className='p-0 ps-2'
aria-label='close'
onClick={() => {
- if (toast.onCloseCallback) toast.onCloseCallback();
- removeToast(toast.id);
+ if (toast.onCloseCallback) toast.onCloseCallback()
+ removeToast(toast.id)
}}
>X
diff --git a/pages/settings.js b/pages/settings.js
index 121727520..7eab851a9 100644
--- a/pages/settings.js
+++ b/pages/settings.js
@@ -15,10 +15,9 @@ import Info from '../components/info'
import Link from 'next/link'
import AccordianItem from '../components/accordian-item'
import { bech32 } from 'bech32'
-import { NOSTR_MAX_RELAY_NUM, NOSTR_PUBKEY_BECH32 } from '../lib/nostr'
+import { NOSTR_MAX_RELAY_NUM, NOSTR_PUBKEY_BECH32, DEFAULT_CROSSPOSTING_RELAYS } from '../lib/nostr'
import { emailSchema, lastAuthRemovalSchema, settingsSchema } from '../lib/validate'
import { SUPPORTED_CURRENCIES } from '../lib/currency'
-import {DEFAULT_CROSSPOSTING_RELAYS} from '../lib/nostr'
import PageLoading from '../components/page-loading'
import { useShowModal } from '../components/modal'
import { authErrorMessage } from '../components/login'
@@ -322,9 +321,9 @@ export default function Settings ({ ssrData }) {
we use your NIP-05 relays if set
otherwise we default to these relays:
- {DEFAULT_CROSSPOSTING_RELAYS.map((relay, i) => (
- - {relay}
- ))}
+ {DEFAULT_CROSSPOSTING_RELAYS.map((relay, i) => (
+ - {relay}
+ ))}