diff --git a/src/components/Publish/EditPlaylist/EditPlaylist.tsx b/src/components/Publish/EditPlaylist/EditPlaylist.tsx index 59e0de6..10eb17d 100644 --- a/src/components/Publish/EditPlaylist/EditPlaylist.tsx +++ b/src/components/Publish/EditPlaylist/EditPlaylist.tsx @@ -338,7 +338,7 @@ export const EditPlaylist = () => { action: "PUBLISH_QDN_RESOURCE", name: username, service: "PLAYLIST", - file: objectToFile(playlistObject), + data64: await objectToBase64(playlistObject), title: title.slice(0, 50), description: metadescription, identifier: identifier, diff --git a/src/components/Publish/EditVideo/EditVideo.tsx b/src/components/Publish/EditVideo/EditVideo.tsx index d06c894..05688d6 100644 --- a/src/components/Publish/EditVideo/EditVideo.tsx +++ b/src/components/Publish/EditVideo/EditVideo.tsx @@ -304,7 +304,7 @@ export const EditVideo = () => { action: "PUBLISH_QDN_RESOURCE", name: username, service: "DOCUMENT", - file: objectToFile(videoObject), + data64: await objectToBase64(videoObject), title: title.slice(0, 50), description: metadescription, identifier: editVideoProperties.id, diff --git a/src/components/Publish/PublishVideo/PublishVideo.tsx b/src/components/Publish/PublishVideo/PublishVideo.tsx index 2f55863..a14bf63 100644 --- a/src/components/Publish/PublishVideo/PublishVideo.tsx +++ b/src/components/Publish/PublishVideo/PublishVideo.tsx @@ -38,7 +38,11 @@ import { useDropzone } from "react-dropzone"; import AddIcon from "@mui/icons-material/Add"; import { setNotification } from "../../../state/features/notificationsSlice.ts"; -import { objectToBase64, objectToFile, uint8ArrayToBase64 } from "../../../utils/PublishFormatter.ts"; +import { + objectToBase64, + objectToFile, + uint8ArrayToBase64, +} from "../../../utils/PublishFormatter.ts"; import { RootState } from "../../../state/store.ts"; import { upsertVideosBeginning, @@ -65,7 +69,11 @@ import { QTUBE_PLAYLIST_BASE, QTUBE_VIDEO_BASE, } from "../../../constants/Identifiers.ts"; -import { maxSize, titleFormatter, videoMaxSize } from "../../../constants/Misc.ts"; +import { + maxSize, + titleFormatter, + videoMaxSize, +} from "../../../constants/Misc.ts"; import { getFileName } from "../../../utils/stringFunctions.ts"; export const toBase64 = (file: File): Promise => @@ -138,7 +146,6 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => { useState(false); const [imageExtracts, setImageExtracts] = useState({}); - const { getRootProps, getInputProps } = useDropzone({ accept: { "video/*": [], @@ -316,7 +323,7 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => { action: "PUBLISH_QDN_RESOURCE", name: name, service: "DOCUMENT", - file: objectToFile(videoObject), + data64: await objectToBase64(videoObject), title: title.slice(0, 50), description: metadescription, identifier: identifier + "_metadata", @@ -396,13 +403,12 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => { `**category:${category};subcategory:${subcategory};${codes}**` + stringDescription.slice(0, 120); - // Description is obtained from raw data const requestBodyJson: any = { action: "PUBLISH_QDN_RESOURCE", name: name, service: "PLAYLIST", - file: objectToFile(playlistObject), + data64: await objectToBase64(playlistObject), title: title.slice(0, 50), description: metadescription, identifier: identifier + "_metadata", @@ -451,13 +457,12 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => { `**category:${playlistObject.category};subcategory:${playlistObject.subcategory};${codes}**` + playlistObject.description.slice(0, 120); - // Description is obtained from raw data const requestBodyJson: any = { action: "PUBLISH_QDN_RESOURCE", name: name, service: "PLAYLIST", - file: objectToFile( playlistObject), + data64: await objectToBase64(playlistObject), title: playlistObject.title.slice(0, 50), description: metadescription, identifier: selectExistingPlaylist.identifier, @@ -596,7 +601,9 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => { compressedFile = file; resolve(); }, - error(error) {console.log(error)}, + error(error) { + console.log(error); + }, }); }); if (!compressedFile) continue; @@ -613,7 +620,9 @@ export const PublishVideo = ({ editId, editContent }: NewCrowdfundProps) => { [index]: imagesExtracts, }; }); - } catch (error) {console.log(error)} + } catch (error) { + console.log(error); + } }; return ( diff --git a/src/components/ResponsiveImage.tsx b/src/components/ResponsiveImage.tsx index f4412a8..2877ce5 100644 --- a/src/components/ResponsiveImage.tsx +++ b/src/components/ResponsiveImage.tsx @@ -28,7 +28,7 @@ const ResponsiveImage: React.FC = ({ }, endTimeMilliSeconds); }; - useEffect(() => endLoading(5), []); + useEffect(() => endLoading(30), [endLoading]); return ( { break; } }; - function publishLike(chosenLikeType: LikeType) { + const publishLike = async (chosenLikeType: LikeType) => { if (isLoading) { dispatch( setNotification({ @@ -118,21 +118,17 @@ export const LikeAndDislike = ({ name, identifier }: LikeAndDislikeProps) => { throw new Error("Could not retrieve content creator's address"); }); - objectToBase64({ - likeType: chosenLikeType, - }).then(likeToBase64 => { - qortalRequest({ - action: "PUBLISH_QDN_RESOURCE", - name: username, - service: "CHAIN_COMMENT", - data64: likeToBase64, - title: "", - identifier: likeIdentifier, - filename: `like_metadata.json`, - }).then(() => { - updateLikeDataState(chosenLikeType); - }); + await qortalRequest({ + action: "PUBLISH_QDN_RESOURCE", + name: username, + service: "CHAIN_COMMENT", + data64: await objectToBase64({ likeType: chosenLikeType }), + title: "", + identifier: likeIdentifier, + filename: `like_metadata.json`, }); + + updateLikeDataState(chosenLikeType); } catch (error: any) { dispatch( setNotification({ @@ -146,7 +142,7 @@ export const LikeAndDislike = ({ name, identifier }: LikeAndDislikeProps) => { ); throw new Error("Failed to publish Super Like"); } - } + }; return ( <> diff --git a/src/components/common/ContentButtons/SuperLike.tsx b/src/components/common/ContentButtons/SuperLike.tsx index b519f4d..7e2c4db 100644 --- a/src/components/common/ContentButtons/SuperLike.tsx +++ b/src/components/common/ContentButtons/SuperLike.tsx @@ -129,7 +129,7 @@ export const SuperLike = ({ 39 )}_${id}`; - const superLikeToFile = objectToFile({ + const superLikeToBase64 = await objectToBase64({ comment, transactionReference: res.signature, notificationInformation: { @@ -147,7 +147,7 @@ export const SuperLike = ({ action: "PUBLISH_QDN_RESOURCE", name: username, service: "BLOG_COMMENT", - file: superLikeToFile, + data64: superLikeToBase64, title: "", description: metadescription, identifier: identifierSuperLike, diff --git a/src/components/common/SuperLikesList/CommentEditor.tsx b/src/components/common/SuperLikesList/CommentEditor.tsx index b2917b7..b6af500 100644 --- a/src/components/common/SuperLikesList/CommentEditor.tsx +++ b/src/components/common/SuperLikesList/CommentEditor.tsx @@ -1,23 +1,22 @@ -import { Box, Button, TextField } from "@mui/material"; +import localforage from "localforage"; import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { RootState } from "../../../state/store"; import ShortUniqueId from "short-unique-id"; +import { COMMENT_BASE } from "../../../constants/Identifiers.ts"; import { setNotification } from "../../../state/features/notificationsSlice"; +import { addtoHashMapSuperlikes } from "../../../state/features/videoSlice"; +import { RootState } from "../../../state/store"; import { objectToBase64, objectToFile, - publishFormatter, stringToFile, } from "../../../utils/PublishFormatter.ts"; -import localforage from "localforage"; import { CommentInput, CommentInputContainer, SubmitCommentButton, } from "./Comments-styles"; -import { addtoHashMapSuperlikes } from "../../../state/features/videoSlice"; -import { COMMENT_BASE } from "../../../constants/Identifiers.ts"; + const uid = new ShortUniqueId(); const notification = localforage.createInstance({ @@ -160,7 +159,7 @@ export const CommentEditor = ({ } try { - let dataFile = null; + let dataFile: string = null; let description = ""; let tag1 = ""; let superObj = {}; @@ -181,8 +180,7 @@ export const CommentEditor = ({ notificationInformation: comment.notificationInformation, about: comment.about, }; - const superLikeToFile = objectToFile(superObj); - dataFile = superLikeToFile; + dataFile = await objectToBase64(superObj); } if (isSuperLike && !dataFile) throw new Error("unable to edit Super like"); @@ -191,7 +189,7 @@ export const CommentEditor = ({ action: "PUBLISH_QDN_RESOURCE", name: name, service: "BLOG_COMMENT", - file: isSuperLike ? dataFile : stringToFile(value), + data64: isSuperLike ? dataFile : utf8ToBase64(value), identifier: identifier, description, tag1, diff --git a/src/components/common/VideoPlayer/VideoPlayer.tsx b/src/components/common/VideoPlayer/VideoPlayer.tsx index 3cbfc5e..4097bf7 100644 --- a/src/components/common/VideoPlayer/VideoPlayer.tsx +++ b/src/components/common/VideoPlayer/VideoPlayer.tsx @@ -147,7 +147,7 @@ export const VideoPlayer = React.forwardRef( const increaseSpeed = (wrapOverflow = true) => { const changedSpeed = playbackRate + speedChange; - let newSpeed = wrapOverflow + const newSpeed = wrapOverflow ? changedSpeed : Math.min(changedSpeed, maxSpeed); @@ -194,6 +194,7 @@ export const VideoPlayer = React.forwardRef( identifier, }); } catch (error) { + console.log(error); } finally { isFetchingProperties.current = false; } @@ -201,8 +202,10 @@ export const VideoPlayer = React.forwardRef( const toggleRef = useRef(null); const { downloadVideo } = useContext(MyContext); - const togglePlay = async (event?: any, isPlay?: boolean) => { + + const togglePlay = (event?: any, isPlay?: boolean) => { if (!videoRef.current) return; + setStartPlay(true); if (!src || resourceStatus?.status !== "READY") { const el = document.getElementById("videoWrapper"); @@ -429,7 +432,7 @@ export const VideoPlayer = React.forwardRef( function formatTime(seconds: number): string { seconds = Math.floor(seconds); - let minutes: number | string = Math.floor(seconds / 60); + const minutes: number | string = Math.floor(seconds / 60); let hours: number | string = Math.floor(minutes / 60); let remainingSeconds: number | string = seconds % 60; @@ -473,7 +476,9 @@ export const VideoPlayer = React.forwardRef( clearInterval(interval); } }, 7500); - } catch (error) {} + } catch (error) { + console.log(error); + } }; useEffect(() => {