import React, { useState } from "react"; import DownloadLink from "./DownloadLink"; import * as Utils from "../utils"; import LinkInput from "./LinkInput"; import { API_URL } from "../constants"; // import * as Actions from "../redux/actionCreators"; import * as Selectors from "../redux/selectors"; import * as Actions from "../redux/actionCreators"; import { useSelector } from "react-redux"; // import { useActionCreator } from "../hooks"; import DownloadText from "./DownloadText"; import { useActionCreator } from "../hooks"; function Metadata() { const hash = useSelector(Selectors.getSelectedSkinHash); const skinData = useSelector((state) => state.skins[hash] || null); console.log(skinData); const fileName = skinData && skinData.fileName; const permalink = useSelector( Selectors.getAbsolutePermalinkUrlFromHashGetter )(hash); // const toggleFileExplorer = useActionCreator(Actions.toggleFileExplorer); const focusedSkinFile = useSelector(Selectors.getFocusedSkinFile); const markNsfw = useActionCreator(Actions.markNsfw); const [showLink, setShowLink] = useState(false); // TODO: Move to Epic async function report(e) { e.preventDefault(); markNsfw(hash); } let readmeLink = null; if ( focusedSkinFile != null && focusedSkinFile.content != null && focusedSkinFile.fileName != null ) { readmeLink = ( Readme ); } const elements = [ Download , readmeLink, /* , */ { setShowLink((s) => !s); e.preventDefault(); }} > Share , Webamp , skinData && skinData.nsfw ? ( "NSFW" ) : ( ), ].filter(Boolean); return (
{showLink && ( setShowLink(false)} /> )} {fileName || "Filename loading..."}{" "} {elements.map((element, i) => { const last = i === element.length - 1; return ( {"["} {element} {"]"} {last ? "" : " "} ); })}
); } export default Metadata;