chore: formatting

This commit is contained in:
2023-10-21 21:46:15 +01:00
parent 0e3661afc6
commit 63950f1e6b
4 changed files with 45 additions and 34 deletions

View File

@ -307,18 +307,18 @@ export function NoteCreator() {
onChange={e => { onChange={e => {
note.update( note.update(
v => v =>
(v.selectedCustomRelays = (v.selectedCustomRelays =
// set false if all relays selected // set false if all relays selected
e.target.checked && e.target.checked &&
note.selectedCustomRelays && note.selectedCustomRelays &&
note.selectedCustomRelays.length == a.length - 1 note.selectedCustomRelays.length == a.length - 1
? undefined ? undefined
: // otherwise return selectedCustomRelays with target relay added / removed : // otherwise return selectedCustomRelays with target relay added / removed
a.filter(el => a.filter(el =>
el === r el === r
? e.target.checked ? e.target.checked
: !note.selectedCustomRelays || note.selectedCustomRelays.includes(el), : !note.selectedCustomRelays || note.selectedCustomRelays.includes(el),
)), )),
); );
}} }}
/> />
@ -387,9 +387,9 @@ export function NoteCreator() {
onChange={e => onChange={e =>
note.update( note.update(
v => v =>
(v.zapSplits = arr.map((vv, ii) => (v.zapSplits = arr.map((vv, ii) =>
ii === i ? { ...vv, weight: Number(e.target.value) } : vv, ii === i ? { ...vv, weight: Number(e.target.value) } : vv,
)), )),
) )
} }
/> />
@ -580,13 +580,7 @@ export function NoteCreator() {
if (!note.show) return null; if (!note.show) return null;
return ( return (
<Modal id="note-creator" className="note-creator-modal" onClose={reset}> <Modal id="note-creator" className="note-creator-modal" onClose={reset}>
{note.sending && ( {note.sending && <NoteBroadcaster evs={note.sending} onClose={reset} customRelays={note.selectedCustomRelays} />}
<NoteBroadcaster
evs={note.sending}
onClose={reset}
customRelays={note.selectedCustomRelays}
/>
)}
{!note.sending && noteCreatorForm()} {!note.sending && noteCreatorForm()}
</Modal> </Modal>
); );

View File

@ -28,23 +28,36 @@ export const NoteCreatorButton = ({ className }: { className?: string }) => {
const shouldHideNoteCreator = useMemo(() => { const shouldHideNoteCreator = useMemo(() => {
const isReply = replyTo && show; const isReply = replyTo && show;
const hideOn = ["/settings", "/messages", "/new", "/login", "/donate", "/e", "/nevent", "/note1", "/naddr", "/subscribe"]; const hideOn = [
"/settings",
"/messages",
"/new",
"/login",
"/donate",
"/e",
"/nevent",
"/note1",
"/naddr",
"/subscribe",
];
return (readonly || hideOn.some(a => location.pathname.startsWith(a))) && !isReply; return (readonly || hideOn.some(a => location.pathname.startsWith(a))) && !isReply;
}, [location, readonly]); }, [location, readonly]);
return ( return (
<> <>
{!shouldHideNoteCreator && <button {!shouldHideNoteCreator && (
ref={buttonRef} <button
className={classNames("primary circle", className)} ref={buttonRef}
onClick={() => className={classNames("primary circle", className)}
update(v => { onClick={() =>
v.replyTo = undefined; update(v => {
v.show = true; v.replyTo = undefined;
}) v.show = true;
}> })
<Icon name="plus" size={16} /> }>
</button>} <Icon name="plus" size={16} />
</button>
)}
<NoteCreator key="global-note-creator" /> <NoteCreator key="global-note-creator" />
</> </>
); );

View File

@ -38,5 +38,7 @@ export default function Modal(props: ModalProps) {
{props.children} {props.children}
</div> </div>
</div> </div>
</div>, document.body); </div>,
document.body,
);
} }

View File

@ -51,5 +51,7 @@ export default function Toaster() {
{a.element} {a.element}
</div> </div>
))} ))}
</div>, document.body); </div>,
document.body,
);
} }