From 8380c8e091b025f1857eedaeabab5121a1f1bca5 Mon Sep 17 00:00:00 2001 From: danidfra Date: Thu, 3 Oct 2024 15:30:51 -0300 Subject: [PATCH] Update: Add NIP-05 warning to Post Composer --- src/features/compose/components/compose-form.tsx | 5 +++-- src/features/compose/editor/index.tsx | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/features/compose/components/compose-form.tsx b/src/features/compose/components/compose-form.tsx index 79946dcf6..ea0a5341d 100644 --- a/src/features/compose/components/compose-form.tsx +++ b/src/features/compose/components/compose-form.tsx @@ -17,7 +17,7 @@ import AutosuggestInput, { AutoSuggestion } from 'soapbox/components/autosuggest import { Button, HStack, Stack } from 'soapbox/components/ui'; import EmojiPickerDropdown from 'soapbox/features/emoji/containers/emoji-picker-dropdown-container'; import { ComposeEditor } from 'soapbox/features/ui/util/async-components'; -import { useAppDispatch, useAppSelector, useCompose, useDraggedFiles, useFeatures, useInstance, usePrevious } from 'soapbox/hooks'; +import { useAppDispatch, useAppSelector, useCompose, useDraggedFiles, useFeatures, useInstance, useOwnAccount, usePrevious } from 'soapbox/hooks'; import QuotedStatusContainer from '../containers/quoted-status-container'; import ReplyIndicatorContainer from '../containers/reply-indicator-container'; @@ -69,6 +69,7 @@ const ComposeForm = ({ id, shouldCondense, autoFocus, clickab const intl = useIntl(); const dispatch = useAppDispatch(); const { configuration } = useInstance(); + const { account } = useOwnAccount(); const compose = useCompose(id); const showSearch = useAppSelector((state) => state.search.submitted && !state.search.hidden); @@ -108,7 +109,7 @@ const ComposeForm = ({ id, shouldCondense, autoFocus, clickab const isEmpty = !(fulltext.trim() || anyMedia); const condensed = shouldCondense && !isDraggedOver && !composeFocused && isEmpty && !isUploading; const shouldAutoFocus = autoFocus && !showSearch; - const canSubmit = !!editorRef.current && !isSubmitting && !isUploading && !isChangingUpload && !isEmpty && length(fulltext) <= maxTootChars; + const canSubmit = !!editorRef.current && !isSubmitting && !isUploading && !isChangingUpload && !isEmpty && length(fulltext) <= maxTootChars && account?.source?.nostr?.nip05 !== undefined; const getClickableArea = () => { return clickableAreaRef ? clickableAreaRef.current : formRef.current; diff --git a/src/features/compose/editor/index.tsx b/src/features/compose/editor/index.tsx index eeb6c1f02..024268de2 100644 --- a/src/features/compose/editor/index.tsx +++ b/src/features/compose/editor/index.tsx @@ -18,7 +18,8 @@ import { $createParagraphNode, $createTextNode, $getRoot, type LexicalEditor } f import React, { useMemo, useState } from 'react'; import { FormattedMessage } from 'react-intl'; -import { useAppDispatch } from 'soapbox/hooks'; +import Warning from 'soapbox/features/compose/components/warning'; +import { useAppDispatch, useOwnAccount, useSettingsNotifications } from 'soapbox/hooks'; import { useNodes } from './nodes'; import AutosuggestPlugin from './plugins/autosuggest-plugin'; @@ -84,6 +85,8 @@ const ComposeEditor = React.forwardRef(({ }, ref) => { const dispatch = useAppDispatch(); const nodes = useNodes(); + const { account } = useOwnAccount(); + const settingsNotifications = useSettingsNotifications(); const [suggestionsHidden, setSuggestionsHidden] = useState(true); @@ -132,6 +135,9 @@ const ComposeEditor = React.forwardRef(({ return ( + { account?.source?.nostr?.nip05 === undefined ? + Identity\' before continuing.'} /> : } /> : null + }