From d2f46a320e00552a23ddf8e845f179c6f01209da Mon Sep 17 00:00:00 2001 From: appala venkata avinash Date: Fri, 29 Mar 2024 20:27:14 +0530 Subject: [PATCH 1/2] Added tags to post title --- src/components/Post/newPost.js | 494 +++++++++++++++++---------------- 1 file changed, 261 insertions(+), 233 deletions(-) diff --git a/src/components/Post/newPost.js b/src/components/Post/newPost.js index dc379fa..f17b867 100644 --- a/src/components/Post/newPost.js +++ b/src/components/Post/newPost.js @@ -15,6 +15,8 @@ const PostUpload = ({ isOpen, onClose }) => { const [postStage, setPostStage] = useState(0); const [isUploading, setIsUploading] = useState(false); const [showMaxTagsAlert, setShowMaxTagsAlert] = useState(false); + const [showNotification, setShowNotification] = useState(false); + const MAX_TAGS = 3; let alertTimeout = useRef(null); @@ -82,7 +84,7 @@ const PostUpload = ({ isOpen, onClose }) => { ['p', uesrPublicKey], ['category', 'memestrrr'], ], - content: title + ' ' + link, + content: title + ' ' + link + ' ' + hashtags, }; // console.log("event", commentEvent) @@ -95,6 +97,8 @@ const PostUpload = ({ isOpen, onClose }) => { value => { console.log('Success', value); setPostStage(4); // Success! + setShowNotification(true); + setTimeout(() => setShowNotification(false), 3000); }, reason => { console.error('something went wrong', reason); // Error! @@ -236,262 +240,286 @@ const PostUpload = ({ isOpen, onClose }) => { }, []); return ( -
- - - -
- - -
-
- - -
-
-

- Upload -

+ <> +
+ + + +
+ + +
+
+ + +
+
+

+ Upload +

+
+
- -
- -
-
-
-
- -
- -
-
-
- - -
-
-
- - # - -
+ +
+
+
+
+ +
-
- Upto 3 tags, - seperated with - space. -
- {hashtags.map( - (tag, index) => ( -
- {tag} - -
- ), - )} - - {showMaxTagsAlert && ( -
-
-

- Max - allowed - tags: 3 -

-
-
- )}
-
+
+ -
- -
-
- {!preview && - !isUploading && ( - <> - - -

- PNG, - JPG, - GIF, - MP4 - up - to - 10MB -

- - )} - {isUploading && ( -
-
+
+
+
+ + # +
- )} - {preview && ( -
- +
+
+ Upto 3 tags, + seperated with + space. +
+ {hashtags.map( + ( + tag, + index, + ) => ( +
-
- + className="flex items-center text-wrap gap-1 bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded"> + {tag}
+ ), + )} + + {showMaxTagsAlert && ( +
+
+

+ Max + allowed + tags: + 3 +

+
)}
+ +
+ +
+
+ {!preview && + !isUploading && ( + <> + + +

+ PNG, + JPG, + GIF, + MP4 + up + to + 10MB +

+ + )} + {isUploading && ( +
+
+
+ )} + {preview && ( +
+ Preview +
+ + +
+
+ )} +
+
+
-
- -
- -
- - + +
+ +
+ + +
+
+
+
+ {showNotification && ( +
+
+

+ Post Uploaded Successfully +

+ setShowNotification(false)} + />
-
-
-
+ + )} + ); }; From ba2b6cbca948a55ce2c8601fab54d107a4505d3d Mon Sep 17 00:00:00 2001 From: appala venkata avinash Date: Mon, 1 Apr 2024 20:06:13 +0530 Subject: [PATCH 2/2] Appended hashtags and made pop up after uploading new post --- src/components/HashtagTool/index.js | 26 ++++++++++++++++++++++++++ src/components/Post/newPost.js | 28 ++++++++-------------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/components/HashtagTool/index.js b/src/components/HashtagTool/index.js index 9539c42..fde7af6 100644 --- a/src/components/HashtagTool/index.js +++ b/src/components/HashtagTool/index.js @@ -5,6 +5,7 @@ import PostUpload from '../Post/newPost'; import Spinner from '../Spinner'; import Sidebar from './SideBar'; import { ReactComponent as UploadSvg } from '../../Icons/UploadSvg.svg'; +import { ReactComponent as CloseIcon } from '../../Icons/CloseIcon.svg'; const HashTagContext = React.createContext(); @@ -258,6 +259,14 @@ export function HashtagTool() { const { notes, LoadMoreMedia, isLoading, filterTags } = useHashTagContext(); const [newPostModal, setNewPostModal] = useState(false); const [loadingMorePosts, setLoadingMorePosts] = useState(false); + const [showSuccessNotification, setShowSuccessNotification] = + useState(false); + + function handlePostUploadSuccess() { + setShowSuccessNotification(true); + setTimeout(() => setShowSuccessNotification(false), 3000); // Auto-hide after 3 seconds + } + useResetScrollOnFilterChange(filterTags); function showNewPostModal() { @@ -306,8 +315,25 @@ export function HashtagTool() { )} + + {showSuccessNotification && ( +
+
+

+ Post Uploaded Successfully +

+ + setShowSuccessNotification(false) + } + /> +
+
+ )} diff --git a/src/components/Post/newPost.js b/src/components/Post/newPost.js index f17b867..8d24968 100644 --- a/src/components/Post/newPost.js +++ b/src/components/Post/newPost.js @@ -5,7 +5,7 @@ import { ReactComponent as CloseIcon } from '../../Icons/CloseIcon.svg'; import { ReactComponent as UpwardArrow } from '../../Icons/upwardArrow.svg'; import { ReactComponent as UploadNew } from '../../Icons/uploadNewPost.svg'; -const PostUpload = ({ isOpen, onClose }) => { +const PostUpload = ({ isOpen, onClose, onUploadSuccess }) => { const [link, setLink] = useState(null); const [title, setTitle] = useState(''); const [hashtags, setHashtags] = useState([]); @@ -15,7 +15,6 @@ const PostUpload = ({ isOpen, onClose }) => { const [postStage, setPostStage] = useState(0); const [isUploading, setIsUploading] = useState(false); const [showMaxTagsAlert, setShowMaxTagsAlert] = useState(false); - const [showNotification, setShowNotification] = useState(false); const MAX_TAGS = 3; let alertTimeout = useRef(null); @@ -88,6 +87,7 @@ const PostUpload = ({ isOpen, onClose }) => { }; // console.log("event", commentEvent) + console.log('Comment Event: ', commentEvent); commentEvent.id = getEventHash(commentEvent); commentEvent.sig = getSignature(commentEvent, sk.data); @@ -96,12 +96,14 @@ const PostUpload = ({ isOpen, onClose }) => { Promise.resolve(p1).then( value => { console.log('Success', value); - setPostStage(4); // Success! - setShowNotification(true); - setTimeout(() => setShowNotification(false), 3000); + // Call the callback function passed from the parent component + if (onUploadSuccess) { + onUploadSuccess(); // Call the callback if it's provided + } + onClose(); // Close the upload dialog }, reason => { - console.error('something went wrong', reason); // Error! + console.error('something went wrong', reason); // Error handling }, ); }; @@ -494,7 +496,6 @@ const PostUpload = ({ isOpen, onClose }) => { className="inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gradient-to-r from-blue-500 to-teal-500 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:text-sm" onClick={() => { sendNewPostEvent(); - onClose(); }}> Post @@ -506,19 +507,6 @@ const PostUpload = ({ isOpen, onClose }) => { - {showNotification && ( -
-
-

- Post Uploaded Successfully -

- setShowNotification(false)} - /> -
-
- )} ); };