Skip to content

Commit

Permalink
fix: use user's JWT Pinata
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Aug 10, 2023
1 parent d621402 commit b3b478f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/components/videoPlayer/UploadVideoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React, {
useEffect,
} from "react";
import { View, Pressable, StyleSheet, Image, TextInput } from "react-native";
import { useSelector } from "react-redux";
import { v4 as uuidv4 } from "uuid";

import DefaultAlbumImage from "../../../assets/icons/player/album.png";
Expand All @@ -17,9 +18,9 @@ import { useFeedbacks } from "../../context/FeedbacksProvider";
import { useSelectedNetworkId } from "../../hooks/useSelectedNetwork";
import useSelectedWallet from "../../hooks/useSelectedWallet";
import { getUserId } from "../../networks";
import { selectNFTStorageAPI } from "../../store/slices/settings";
import { defaultSocialFeedFee } from "../../utils/fee";
import { ipfsURLToHTTPURL } from "../../utils/ipfs";
import { generateIpfsKey } from "../../utils/social-feed";
import { generateIpfsKey, ipfsURLToHTTPURL } from "../../utils/ipfs";
import {
neutral17,
neutral33,
Expand All @@ -30,7 +31,7 @@ import {
} from "../../utils/style/colors";
import { fontSemibold14 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { LocalFileData } from "../../utils/types/feed";
import { LocalFileData } from "../../utils/types/files";
import { VideoMetaInfo } from "../../utils/types/video";
import { BrandText } from "../BrandText";
import { SVG } from "../SVG";
Expand Down Expand Up @@ -120,6 +121,7 @@ const Step1Component: React.FC<{
const selectedNetworkId = useSelectedNetworkId();
const selectedWallet = useSelectedWallet();
const userId = getUserId(selectedNetworkId, selectedWallet?.address);
const userIPFSKey = useSelector(selectNFTStorageAPI);

const paddingHorizontal = layout.padding_x2_5;
const styles = StyleSheet.create({
Expand Down Expand Up @@ -196,7 +198,8 @@ const Step1Component: React.FC<{
const file = e.target?.files![0];
const video = document.createElement("video");
video.preload = "metadata";
const pinataJWTKey = await generateIpfsKey(selectedNetworkId, userId);
const pinataJWTKey =
userIPFSKey || (await generateIpfsKey(selectedNetworkId, userId));
video.addEventListener("loadedmetadata", async () => {
window.URL.revokeObjectURL(video.src);
if (!pinataJWTKey) {
Expand Down

0 comments on commit b3b478f

Please sign in to comment.